载入中...
搜索中...
未找到
SpriteAnim.cpp
浏览该文件的文档.
2#include <algorithm>
3#include <cmath>
8#include "common/Exception.h"
9#include "graphics/Quad.h"
11
12// SpriteAnim.cpp
13namespace eve::animation {
14
15SpriteAnim::SpriteAnim() = default;
16
18 if (owner_) owner_->unregisterSpriteAnim(this);
19}
20
21void SpriteAnim::setSheet(SpriteSheet *sheet) { sheet_ = sheet; }
22
24 if (!clip) throw Exception("SpriteAnim.play: clip is null");
25 clip_ = clip;
26 time_ = 0.f;
27 playing_ = true;
28 paused_ = false;
29 finished_ = false;
30 loopCount_ = 0;
31 pendingLoops_ = 0;
32 pendingComplete_ = false;
33 speedCurveTime_ = 0.f;
34 refreshFrame();
35 syncBoundQuad();
36}
37
39 play(clip);
40 if (speed_ >= 0.f) speed_ = speed_ == 0.f ? -1.f : -speed_;
41 time_ = clip_->getDuration();
42 if (time_ > 0.f) time_ = std::nextafter(time_, 0.f);
43 refreshFrame();
44 syncBoundQuad();
45}
46
48 playing_ = false;
49 paused_ = false;
50 finished_ = false;
51 time_ = 0.f;
52 clipFrame_ = -1;
53}
54
56 if (playing_) paused_ = true;
57}
58
60 if (playing_ && paused_) paused_ = false;
61}
62
63void SpriteAnim::setSpeed(float speed) { speed_ = speed; }
64
65void SpriteAnim::addSpeedCurveKey(float seconds, float multiplier) {
66 if (seconds < 0.f) throw Exception("SpriteAnim.addSpeedCurveKey: time must be >= 0");
67 speedCurve_.push_back({seconds, multiplier});
68 std::stable_sort(speedCurve_.begin(), speedCurve_.end(),
69 [](const SpeedKey &a, const SpeedKey &b) { return a.time < b.time; });
70}
71
73 speedCurve_.clear();
74 speedCurveTime_ = 0.f;
75}
76
77void SpriteAnim::resetSpeedCurve() { speedCurveTime_ = 0.f; }
78
79float SpriteAnim::sampleSpeedCurve(float seconds) const {
80 if (speedCurve_.empty()) return 1.f;
81 if (speedCurve_.size() == 1 || seconds <= speedCurve_.front().time) return speedCurve_.front().value;
82
83 const float end = speedCurve_.back().time;
84 float t = seconds;
85 if (speedCurveLoop_ && end > 0.f)
86 t = std::fmod(t, end);
87 else if (t >= end)
88 return speedCurve_.back().value;
89
90 for (size_t i = 1; i < speedCurve_.size(); ++i) {
91 if (t <= speedCurve_[i].time) {
92 const SpeedKey &a = speedCurve_[i - 1];
93 const SpeedKey &b = speedCurve_[i];
94 const float span = b.time - a.time;
95 if (span <= 0.f) return b.value;
96 float u = (t - a.time) / span;
97 if (speedCurveInterpolation_ == "smooth")
98 u = u * u * (3.f - 2.f * u);
99 else if (speedCurveInterpolation_ == "cubic")
100 u = u * u * u * (u * (u * 6.f - 15.f) + 10.f);
101 return a.value + (b.value - a.value) * u;
102 }
103 }
104 return speedCurve_.back().value;
105}
106
107float SpriteAnim::getSpeedCurveValue() const { return sampleSpeedCurve(speedCurveTime_); }
108
109void SpriteAnim::setSpeedCurveInterpolation(const std::string &mode) {
110 if (mode != "linear" && mode != "smooth" && mode != "cubic")
111 throw Exception("SpriteAnim.setSpeedCurveInterpolation: expected linear|smooth|cubic");
112 speedCurveInterpolation_ = mode;
113}
114
116 if (!clip_ || frame < 0 || frame >= clip_->getFrameCount())
117 throw Exception("SpriteAnim.setFrame: frame out of range");
118 float t = 0.f;
119 for (int i = 0; i < frame; ++i) t += clip_->getFrameDuration(i);
120 setTime(t);
121}
122
123void SpriteAnim::step(int frames) {
124 if (!clip_ || clip_->getFrameCount() == 0) return;
125 int target = clipFrame_ + frames;
126 if (getLoop()) {
127 const int count = clip_->getFrameCount();
128 target = ((target % count) + count) % count;
129 } else
130 target = std::max(0, std::min(target, clip_->getFrameCount() - 1));
132}
133
135 play(clip);
136 setLoop(false);
137}
139 if (!clip) throw Exception("SpriteAnim.queue: clip is null");
140 queuedClip_ = clip;
141}
143 std::string value = pendingEvent_;
144 pendingEvent_.clear();
145 return value;
146}
147
149 const bool value = pendingComplete_;
150 pendingComplete_ = false;
151 return value;
152}
153
155 const int value = pendingLoops_;
156 pendingLoops_ = 0;
157 return value;
158}
159
160void SpriteAnim::setTime(float seconds) {
161 if (seconds < 0.f) throw Exception("SpriteAnim.setTime: time must be >= 0");
162 time_ = seconds;
163 refreshFrame();
164 if (clipFrame_ >= 0) {
165 const std::string event = clip_->getEvent(clipFrame_);
166 if (!event.empty()) pendingEvent_ = event;
167 }
168 syncBoundQuad();
169}
170
172 loopOverride_ = true;
173 loopValue_ = loop;
174}
175
176bool SpriteAnim::getLoop() const { return loopOverride_ ? loopValue_ : (clip_ && clip_->getLoop()); }
177
179 if (!clip_ || clipFrame_ < 0) return -1;
180 return clip_->getSheetFrame(clipFrame_);
181}
182
184 boundQuad_ = quad;
185 syncBoundQuad();
186}
187
188void SpriteAnim::unbindQuad() { boundQuad_ = nullptr; }
190 boundSprite_ = sprite;
191 syncBoundQuad();
192}
193
195 if (!quad) throw Exception("SpriteAnim.applyToQuad: quad is null");
196 if (!sheet_) throw Exception("SpriteAnim.applyToQuad: sheet is null");
197 int sf = getSheetFrame();
198 if (sf < 0) throw Exception("SpriteAnim.applyToQuad: no current frame");
199 sheet_->applyToQuad(quad, sf);
200}
201
202void SpriteAnim::refreshFrame() {
203 if (!clip_ || clip_->getFrameCount() == 0) {
204 clipFrame_ = -1;
205 return;
206 }
207
208 const float dur = clip_->getDuration();
209 if (dur <= 0.f) {
210 clipFrame_ = 0;
211 return;
212 }
213
214 const bool loop = getLoop();
215 float local = time_;
216 if (loop) {
217 local = std::fmod(local, dur);
218 if (local < 0.f) local += dur;
219 } else if (local >= dur) {
220 clipFrame_ = clip_->getFrameCount() - 1;
221 return;
222 } else if (local < 0.f) {
223 local = 0.f;
224 }
225
226 float acc = 0.f;
227 for (int i = 0; i < clip_->getFrameCount(); ++i) {
228 acc += clip_->getFrameDuration(i);
229 if (local < acc || i == clip_->getFrameCount() - 1) {
230 clipFrame_ = i;
231 return;
232 }
233 }
234 clipFrame_ = clip_->getFrameCount() - 1;
235}
236
237void SpriteAnim::syncBoundQuad() {
238 if (!boundQuad_ || !sheet_) return;
239 int sf = getSheetFrame();
240 if (sf < 0) return;
241 sheet_->applyToQuad(boundQuad_, sf);
242 if (boundSprite_) {
243 boundSprite_->setFrameLayout(sheet_->getFrameSourceWidth(sf), sheet_->getFrameSourceHeight(sf),
244 sheet_->getFrameWidth(sf), sheet_->getFrameHeight(sf), sheet_->getFrameOffsetX(sf),
245 sheet_->getFrameOffsetY(sf));
246 }
247}
248
249bool SpriteAnim::updateUnchecked(float dt) {
250 if (dt < 0.f) throw Exception("SpriteAnim.update: dt must be >= 0");
251 if (!playing_ || paused_ || !clip_) return playing_ || paused_;
252
253 const float previous = time_;
254 const int previousFrame = clipFrame_;
255 const float curveValue = sampleSpeedCurve(speedCurveTime_ + dt * 0.5f);
256 speedCurveTime_ += dt;
257 time_ += dt * speed_ * curveValue;
258 const float dur = clip_->getDuration();
259 const bool loop = getLoop();
260
261 if (dur <= 0.f) {
262 refreshFrame();
263 syncBoundQuad();
264 return true;
265 }
266
267 if (loop) {
268 const int beforeCycle = static_cast<int>(std::floor(previous / dur));
269 const int afterCycle = static_cast<int>(std::floor(time_ / dur));
270 const int crossed = std::abs(afterCycle - beforeCycle);
271 if (crossed > 0) {
272 loopCount_ += crossed;
273 pendingLoops_ += crossed;
274 }
275 } else if ((speed_ >= 0.f && time_ >= dur) || (speed_ < 0.f && time_ <= 0.f)) {
276 time_ = speed_ < 0.f ? 0.f : dur;
277 finished_ = true;
278 playing_ = false;
279 pendingComplete_ = true;
280 if (queuedClip_) {
281 SpriteClip *next = queuedClip_;
282 queuedClip_ = nullptr;
283 loopOverride_ = false;
284 play(next);
285 return true;
286 }
287 refreshFrame();
288 loopOverride_ = false;
289 syncBoundQuad();
290 return false;
291 }
292
293 refreshFrame();
294 if (clipFrame_ != previousFrame && clipFrame_ >= 0) {
295 const std::string event = clip_->getEvent(clipFrame_);
296 if (!event.empty()) pendingEvent_ = event;
297 }
298 syncBoundQuad();
299 return true;
300}
301
303 auto seconds = detail::secondsForStep(step, hasLastTick_, lastTick_, "SpriteAnim");
304 if (!seconds) return eve::Result<void>::failure(seconds.status());
305 updateUnchecked(std::move(seconds).takeValue());
306 lastTick_ = step.tick;
307 hasLastTick_ = true;
309}
310
312 auto step = detail::legacyStep(dt, hasLastTick_, lastTick_, "SpriteAnim");
313 if (!step) {
314 step.ignore("legacy SpriteAnim update");
315 return playing_ || paused_;
316 }
317 auto result = advance(std::move(step).takeValue());
318 result.ignore("legacy SpriteAnim update");
319 return playing_ || paused_;
320}
321
322} // namespace eve::animation
323
324// SpriteClip.cpp
325namespace eve::animation {
326
327SpriteClip::SpriteClip(const std::string &name) : name_(name) {}
328
329void SpriteClip::setName(const std::string &name) { name_ = name; }
330
331void SpriteClip::checkIndex(int index) const {
332 if (index < 0 || index >= getFrameCount())
333 throw Exception("SpriteClip: frame index %d out of range (count=%d)", index, getFrameCount());
334}
335
336void SpriteClip::addFrame(int sheetFrameIndex, float duration) {
337 if (sheetFrameIndex < 0) throw Exception("SpriteClip.addFrame: sheetFrameIndex must be >= 0");
338 if (duration < 0.f) throw Exception("SpriteClip.addFrame: duration must be >= 0");
339 frames_.push_back(Entry{sheetFrameIndex, duration});
340}
341
342void SpriteClip::addFrameByName(SpriteSheet *sheet, const std::string &frameName, float duration) {
343 if (!sheet) throw Exception("SpriteClip.addFrameByName: sheet is null");
344 int idx = sheet->findFrame(frameName);
345 if (idx < 0) throw Exception("SpriteClip.addFrameByName: unknown frame '%s'", frameName.c_str());
347}
348
349void SpriteClip::addRange(int firstSheetFrame, int lastSheetFrame, float fps) {
350 if (firstSheetFrame < 0 || lastSheetFrame < firstSheetFrame)
351 throw Exception("SpriteClip.addRange: expected 0 <= first <= last");
352 if (fps <= 0.f) throw Exception("SpriteClip.addRange: fps must be > 0");
353 const float duration = 1.f / fps;
354 for (int frame = firstSheetFrame; frame <= lastSheetFrame; ++frame) addFrame(frame, duration);
355}
356
357void SpriteClip::setFPS(float fps) {
358 if (fps <= 0.f) throw Exception("SpriteClip.setFPS: fps must be > 0");
359 const float duration = 1.f / fps;
360 for (Entry &entry : frames_) entry.duration = duration;
361}
362
363float SpriteClip::getFPS() const {
364 if (frames_.empty()) return 0.f;
365 const float duration = frames_.front().duration;
366 if (duration <= 0.f) return 0.f;
367 for (const Entry &entry : frames_) {
368 if (std::fabs(entry.duration - duration) > 1e-6f) return 0.f;
369 }
370 return 1.f / duration;
371}
372
373void SpriteClip::addEvent(int clipFrame, const std::string &name) {
374 checkIndex(clipFrame);
375 events_[clipFrame] = name;
376}
377
378std::string SpriteClip::getEvent(int clipFrame) const {
379 auto it = events_.find(clipFrame);
380 return it == events_.end() ? std::string() : it->second;
381}
382
383void SpriteClip::clear() { frames_.clear(); }
384
386 checkIndex(index);
387 return frames_[static_cast<size_t>(index)].sheetFrame;
388}
389
391 checkIndex(index);
392 return frames_[static_cast<size_t>(index)].duration;
393}
394
396 float sum = 0.f;
397 for (const Entry &e : frames_) sum += e.duration;
398 return sum;
399}
400
401float SpriteClip::wrapTime(float timeSeconds) const {
402 if (timeSeconds < 0.f) timeSeconds = 0.f;
403 const float dur = getDuration();
404 if (dur <= 0.f) return 0.f;
405 if (loop_) {
406 float t = std::fmod(timeSeconds, dur);
407 if (t < 0.f) t += dur;
408 return t;
409 }
410 return timeSeconds > dur ? dur : timeSeconds;
411}
412
413int SpriteClip::frameAtTime(float timeSeconds) const {
414 if (frames_.empty()) return -1;
415 float t = wrapTime(timeSeconds);
416 const float dur = getDuration();
417 if (!loop_ && timeSeconds >= dur) return getFrameCount() - 1;
418
419 float acc = 0.f;
420 for (int i = 0; i < getFrameCount(); ++i) {
421 acc += frames_[static_cast<size_t>(i)].duration;
422 if (t < acc || i == getFrameCount() - 1) return i;
423 }
424 return getFrameCount() - 1;
425}
426
427} // namespace eve::animation
428
429// SpriteSheet.cpp
430namespace eve::animation {
431
432void SpriteSheet::checkIndex(int index) const {
433 if (index < 0 || index >= getFrameCount())
434 throw Exception("SpriteSheet: frame index %d out of range (count=%d)", index, getFrameCount());
435}
436
437int SpriteSheet::addFrame(const std::string &name, int x, int y, int w, int h) {
438 return addFrameTrimmed(name, x, y, w, h, w, h, 0, 0);
439}
440
441int SpriteSheet::addFrameTrimmed(const std::string &name, int x, int y, int w, int h, int sourceW, int sourceH,
442 int offsetX, int offsetY) {
443 if (w <= 0 || h <= 0) throw Exception("SpriteSheet.addFrame: width/height must be > 0");
444 Frame f;
445 f.name = name.empty() ? ("frame" + std::to_string(frames_.size())) : name;
446 if (byName_.count(f.name)) throw Exception("SpriteSheet.addFrame: duplicate frame name '%s'", f.name.c_str());
447 f.x = x;
448 f.y = y;
449 f.w = w;
450 f.h = h;
451 f.sourceW = sourceW;
452 f.sourceH = sourceH;
453 f.offsetX = offsetX;
454 f.offsetY = offsetY;
455 int idx = static_cast<int>(frames_.size());
456 byName_[f.name] = idx;
457 frames_.push_back(std::move(f));
458 return idx;
459}
460
462 checkIndex(i);
463 return frames_[size_t(i)].sourceW;
464}
466 checkIndex(i);
467 return frames_[size_t(i)].sourceH;
468}
470 checkIndex(i);
471 return frames_[size_t(i)].offsetX;
472}
474 checkIndex(i);
475 return frames_[size_t(i)].offsetY;
476}
477
478int SpriteSheet::setGrid(int columns, int rows, int frameW, int frameH, int margin, int spacing, int originX,
479 int originY) {
480 if (columns <= 0 || rows <= 0) throw Exception("SpriteSheet.setGrid: columns/rows must be > 0");
481 if (frameW <= 0 || frameH <= 0) throw Exception("SpriteSheet.setGrid: frameW/frameH must be > 0");
482 if (margin < 0 || spacing < 0) throw Exception("SpriteSheet.setGrid: margin/spacing must be >= 0");
483
484 clear();
485 int added = 0;
486 for (int row = 0; row < rows; ++row) {
487 for (int col = 0; col < columns; ++col) {
488 int x = originX + margin + col * (frameW + spacing);
489 int y = originY + margin + row * (frameH + spacing);
490 addFrame("", x, y, frameW, frameH);
491 ++added;
492 }
493 }
494 return added;
495}
496
498 frames_.clear();
499 byName_.clear();
500}
501
502int SpriteSheet::findFrame(const std::string &name) const {
503 auto it = byName_.find(name);
504 return it == byName_.end() ? -1 : it->second;
505}
506
507std::string SpriteSheet::getFrameName(int index) const {
508 checkIndex(index);
509 return frames_[static_cast<size_t>(index)].name;
510}
511
513 checkIndex(index);
514 return frames_[static_cast<size_t>(index)].x;
515}
516
518 checkIndex(index);
519 return frames_[static_cast<size_t>(index)].y;
520}
521
523 checkIndex(index);
524 return frames_[static_cast<size_t>(index)].w;
525}
526
528 checkIndex(index);
529 return frames_[static_cast<size_t>(index)].h;
530}
531
532void SpriteSheet::applyToQuad(graphics::Quad *quad, int frameIndex) const {
533 if (!quad) throw Exception("SpriteSheet.applyToQuad: quad is null");
534 checkIndex(frameIndex);
535 const Frame &f = frames_[static_cast<size_t>(frameIndex)];
536 quad->setViewport(f.x, f.y, f.w, f.h);
537}
538
540 auto *copy = new SpriteSheet();
541 copy->frames_ = frames_;
542 copy->byName_ = byName_;
543 copy->texture_ = texture_;
544 return copy;
545}
546
547} // namespace eve::animation
double y
double x
LogicalId target
float w
Definition AnimClip.cpp:738
float duration
std::string name
Definition ECS.cpp:154
int rows
glm::vec4 clip
float u
Definition Grass.cpp:233
int h
std::string local
Poco::JSON::Object::Ptr result
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
ssq::Object frame
double dt
std::shared_ptr< const OceanSprayFrame > previous
int idx
float f
Object::Ptr value
float t
size_t end
int count
int spacing
int columns
float offsetX
float offsetY
int margin
float step
Definition TreeMesh.cpp:451
uint32_t index
EVENGINE_API_FOUNDATION public API.
Definition Exception.h:13
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
void bindQuad(graphics::Quad *quad)
Keep this Quad's viewport updated each update/play.
bool update(float dt)
Legacy seconds facade; explicitly forwards to advance().
bool consumeCompleted()
Consume and clear the one-shot completion event.
void setLoop(bool loop)
Sets the loop.
void setTime(float seconds)
Sets the time.
void resetSpeedCurve()
Restart speed-curve sampling from zero without changing clip time.
void setSpeedCurveInterpolation(const std::string &mode)
Set speed-curve interpolation: linear, smooth, or cubic.
void play(SpriteClip *clip)
Play.
void clearSpeedCurve()
Remove all speed-curve keys and restore constant-speed playback.
void setSpeed(float speed)
Sets the speed.
void step(int frames)
Step.
void setSheet(SpriteSheet *sheet)
Optional sheet used by applyToQuad / bindQuad.
void queue(SpriteClip *clip)
Queue.
void addSpeedCurveKey(float seconds, float multiplier)
Add a piecewise-linear speed multiplier key at curve time in seconds.
float getSpeedCurveValue() const
Return the current sampled curve multiplier.
void unbindQuad()
Unbinds quad.
void bindSprite(graphics::Renderable2D *sprite)
Bind a Sprite2D so trimmed frame layout is synchronized automatically.
void applyToQuad(graphics::Quad *quad) const
Write current sheet frame into quad (requires sheet).
bool getLoop() const
Returns the loop.
std::string consumeEvent()
Consume event.
void playReverse(SpriteClip *clip)
Start at the clip end and play backward (speed becomes negative).
eve::Result< void > advance(const eve::SimulationStep &step)
Advance playback. Returns true while still active (playing or paused). Auto-applies to boundQuad when...
void playOnce(SpriteClip *clip)
Play once.
int consumeLooped()
Consume and clear pending loop events, returning their count.
int getSheetFrame() const
Sheet frame index for the current cell, or -1.
void setFrame(int clipFrame)
Sets the frame.
Named 2D frame sequence referencing SpriteSheet frame indices. Script type: SpriteClip.
Definition SpriteClip.h:17
SpriteClip(const std::string &name="")
Sprite clip.
int getSheetFrame(int index) const
Returns the sheet frame.
void addEvent(int clipFrame, const std::string &name)
Attach a named event to a clip-frame index.
float wrapTime(float timeSeconds) const
Local time wrapped or clamped according to loop flag.
float getFPS() const
Uniform FPS, or 0 when empty/variable-duration.
void addFrame(int sheetFrameIndex, float duration=0.1f)
Append one cell: sheetFrameIndex + display duration (seconds).
float getDuration() const
Returns the duration.
void setName(const std::string &name)
Sets the name.
void addFrameByName(SpriteSheet *sheet, const std::string &frameName, float duration=0.1f)
Resolve name via sheet and append.
void setFPS(float fps)
Replace every existing frame duration with 1/fps.
int frameAtTime(float timeSeconds) const
Map absolute time (seconds) into a clip frame index. When loop is false and t >= duration,...
int getFrameCount() const
Returns the frame count.
Definition SpriteClip.h:58
void addRange(int firstSheetFrame, int lastSheetFrame, float fps)
Append inclusive sheet-frame range at a uniform frame rate.
std::string getEvent(int clipFrame) const
Return event name for a frame, or empty when none.
bool getLoop() const
Returns the loop.
Definition SpriteClip.h:35
float getFrameDuration(int index) const
Returns the frame duration.
Sprite-sheet / texture-atlas frame table (pixel rects).
Definition SpriteSheet.h:23
SpriteSheet()=default
Sprite sheet.
int getFrameCount() const
Returns the frame count.
Definition SpriteSheet.h:56
int getFrameX(int index) const
Returns the frame x.
int getFrameOffsetX(int index) const
Returns the frame offset x.
int addFrame(const std::string &name, int x, int y, int w, int h)
Append a named frame. Returns frame index. Empty name → "frameN".
int getFrameSourceWidth(int index) const
Returns the frame source width.
int setGrid(int columns, int rows, int frameW, int frameH, int margin=0, int spacing=0, int originX=0, int originY=0)
Generate frames in row-major order from a grid. frameW/frameH are cell sizes; margin is outer padding...
std::string getFrameName(int index) const
Returns the frame name.
int getFrameWidth(int index) const
Returns the frame width.
SpriteSheet * clone() const
Duplicate frame metadata while sharing the borrowed atlas texture.
int getFrameHeight(int index) const
Returns the frame height.
int getFrameY(int index) const
Returns the frame y.
int getFrameOffsetY(int index) const
Returns the frame offset y.
int findFrame(const std::string &name) const
Finds frame.
void applyToQuad(graphics::Quad *quad, int frameIndex) const
Write pixel viewport into an existing Quad (does not allocate).
int getFrameSourceHeight(int index) const
Returns the frame source height.
int addFrameTrimmed(const std::string &name, int x, int y, int w, int h, int sourceW, int sourceH, int offsetX, int offsetY)
Append a trimmed frame with original canvas size and content offset.
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
void setViewport(int x, int y, int w, int h)
Sets the viewport.
Definition Quad.cpp:11
Default renderable entity for declarative 2D sprites / solid quads.
void setFrameLayout(int sourceW, int sourceH, int trimW, int trimH, int offsetX, int offsetY)
Apply trimmed-frame layout while preserving the original canvas origin.
eve::Result< eve::SimulationStep > legacyStep(float seconds, bool hasLastTick, eve::SimulationTick lastTick, const char *owner)
Convert a legacy seconds call to the next local scheduler step.
eve::Result< float > secondsForStep(const eve::SimulationStep &step, bool hasLastTick, eve::SimulationTick lastTick, const char *owner)
Validate a scheduler step before an animation object mutates state.
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
One deterministic fixed-step emitted by SimulationClock.
Definition Time.h:158