102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference | GitLab repository
Loading...
Searching...
No Matches
model.c
Go to the documentation of this file.
1/* Recovered game implementation; original addresses identify provenance. */
12#include "pcdogs/scene/types.h"
13#include "pcdogs/image/values.h"
14
15static uint16_t animation_delay(const struct Animation_DataBlock *animation, bool paused)
16{
17 return paused ? 0 : (animation->fixup_flags & ~ANIMATION_DATA_DELAY_CONTROL_MASK) << 3;
18}
19
20// Original pcdogs.exe: 0x40e490
22{
23 bool paused = (actor->render_node_list[0]->traversal_flags & SCENE_NODE_DISABLED) != 0;
24 if (!paused)
25 {
26 actor->anim_tick = (int32_t)((uint32_t)actor->anim_tick + actor->move_anim_speed);
27 const struct Animation_DataBlock *current = actor->anim_asset_table->anim_ptrs[(uint16_t)actor->anim_seq_index];
28 if (current)
29 {
30 int32_t elapsed = (int32_t)((uint32_t)actor->anim_tick - actor->anim_frame_time);
31 int32_t duration = (current->keyframe_range.max - current->keyframe_range.min + 1) * 64;
32 if (elapsed >= duration)
33 {
35 actor->anim_frame_time = (int32_t)((uint32_t)actor->anim_frame_time + duration);
36 else
37 actor->anim_tick = (int32_t)((uint32_t)actor->anim_tick - duration);
38 }
39 else if (elapsed >= actor->anim_seq_timer)
40 actor->anim_seq_timer = 0;
41 }
42 }
43
44 // The queue belongs to the whole scene. The next actor consumes it in reverse order.
46 {
47 int32_t top = g_animationStateQueueCount - 1;
48 int32_t index = g_animQueuedStateChange[top];
50 const struct Animation_DataBlock *queued = actor->anim_asset_table->anim_ptrs[index];
51 if (!queued)
52 continue;
53
56 else
57 {
59 actor->anim_tick = 0;
60 actor->anim_seq_index = (int16_t)index;
61 actor->anim_seq_timer = animation_delay(queued, paused);
62 actor->anim_frame_time = actor->anim_tick;
63 }
64
65 for (struct Scene_Node **slot = actor->render_node_list; *slot; ++slot)
66 {
67 struct Scene_Node *node = *slot;
68 bool check_visibility = (queued->fixup_flags & ANIMATION_DATA_NODE_STATE) != 0;
69 if (!check_visibility)
70 {
71 const struct Animation_DataBlock *previous = actor->anim_asset_table->anim_ptrs[node->anim_update_sentinel];
72 check_visibility = previous && (previous->fixup_flags & ANIMATION_DATA_NODE_STATE);
73 }
74 if (check_visibility)
75 {
76 int visibility_index = node->visibility_anim_channel_index_or_minus_one;
77 if (visibility_index < 0 || !(queued->visibility_channels[visibility_index].channel_flags & ANIMATION_SPLINE_ACCEPT_QUEUED_STATE))
78 continue;
79 }
80 node->anim_update_sentinel = (uint16_t)index;
81 node->animation_delay = animation_delay(queued, paused);
82 node->cached_anim_tick = actor->anim_tick;
83 }
84 }
85
88}
89
90// Original pcdogs.exe: 0x43a700
91// Clears the model's animation behavior flag, marks its render state dirty, and resets trail-chain and component animation state.
#define ACTOR_BEHAVIOR_ANIMATION_PENDING
Definition constants.h:27
#define ACTOR_BEHAVIOR_DESTROY_AFTER_ANIMATION
Definition constants.h:28
#define ACTOR_LIFECYCLE_DESTROYING
Definition constants.h:43
void Actor_ResetComponentAnimations(struct Actor_State *actor)
Definition animation.c:729
void Actor_ResetAnimationChains(struct Actor_State *actor)
Definition animation.c:714
int32_t Actor_GetAnimationProgress(struct Actor_State *actor)
Definition animation.c:526
#define ANIMATION_DATA_DELAY_CONTROL_MASK
Definition constants.h:35
#define ANIMATION_DATA_NODE_STATE
Definition constants.h:33
#define ANIMATION_SPLINE_ACCEPT_QUEUED_STATE
Definition constants.h:32
#define g_animationStateQueueCount
Definition globals.h:25
void Graphics_MarkMeshDirty(struct Mesh_CmdList *cmd_list)
Definition meshes.c:33
#define MATH_Q12_ONE
Definition constants.h:9
static uint16_t animation_delay(const struct Animation_DataBlock *animation, bool paused)
Definition model.c:15
void Model_AdvanceAnimation(struct Actor_State *actor)
Definition model.c:21
void Model_ResetState(struct Actor_State *actor)
Definition model.c:92
#define SCENE_NODE_DISABLED
Definition constants.h:24
#define SCENE_OWNER_TRAILS_ACTIVE
Definition constants.h:35
int16_t anim_seq_timer
Definition types.h:389
struct Animation_ControllerGroup * anim_ctrl_ptr
Definition types.h:401
int16_t move_anim_speed
Definition types.h:428
struct Scene_Node ** render_node_list
Definition types.h:440
int32_t anim_frame_time
Definition types.h:390
uint8_t lifecycle_flags
Definition types.h:392
struct Animation_StateTable * anim_asset_table
Definition types.h:425
int32_t behavior_flags
Definition types.h:407
int32_t anim_tick
Definition types.h:427
int16_t anim_seq_index
Definition types.h:388
Animation_DataBlockFixupFlags fixup_flags
Definition types.h:761
struct Animation_SplineChannelVis * visibility_channels
Definition types.h:766
struct Math_RangeI16 keyframe_range
Definition types.h:763
Animation_SplineChannelFlags channel_flags
Definition types.h:400
struct Animation_DataBlock * anim_ptrs[0x2b]
Definition types.h:422
int16_t max
Definition types.h:232
int16_t min
Definition types.h:231
uint16_t anim_update_sentinel
Definition types.h:126
int32_t cached_anim_tick
Definition types.h:128
uint16_t animation_delay
Definition types.h:127
uint8_t traversal_flags
Definition types.h:130
char visibility_anim_channel_index_or_minus_one
Definition types.h:124
#define g_animQueuedStateChange
Definition values.h:174