36 int64_t angle_conversion_product;
38 int16_t entity_initial_facing;
43 entity_initial_facing = (int16_t)entity->
param_F0;
50 int32_t scaled_entity_index;
54 int32_t entity_index_product_high;
56 entity_index_product_high =
59 scaled_entity_index = entity_index_product_high >> 6;
62 if (target_selector ==
ACTOR_FACING_RELATIVE || target_selector == scaled_entity_index + (scaled_entity_index >> 0x1f) + 1)
63 angle_degrees_q12 += (int32_t)entity_initial_facing;
66 int32_t attach_offset_x;
78 int32_t target_delta_x = entity->
path_result.
x - position_ptr->
x;
79 int32_t target_delta_z = entity->
path_result.
z - position_ptr->
z;
82 .
x = saved_path_result_x,
83 .y = saved_path_result_y,
84 .z = saved_path_result_z};
87 return (uint8_t)attach_offset_x;
92 else if (target_selector > 0)
96 (
struct Actor_State *)entity_array[target_selector - 1].runtime_actor;
97 int32_t target_entity_facing;
101 uint16_t target_blend_bits = target_actor->
facing_blend;
102 uint16_t target_current_facing_bits = target_actor->
facing_current;
104 target_entity_facing = (target_blend_bits + target_current_facing_bits) &
PHYSICS_ANGLE_MASK;
107 target_entity_facing = entity_array[target_selector - 1].
param_F0;
109 angle_degrees_q12 += target_entity_facing;
119 return entity_initial_facing == target_facing_q12;
153 move_target_position = &movement_record->
move_target;
156 move_target_position->
x = 0;
160 move_target_position = &movement_record->
move_target;
162 move_target_position->
x = target_pos->
x;
163 move_target_position->
y = target_pos->
y;
164 move_target_position->
z = target_pos->
z;
167 int32_t delta_x = move_target_position->
x - actor->
position.
x;
170 int32_t saved_target_delta_y = delta_y;
172 for (int32_t component_index = 0; component_index < 2; component_index++)
190 delta_y = saved_target_delta_y;
202 if (!(uint16_t)duration_frames)
210 int64_t velocity_x_product_wide = (int64_t)step_scale_q12 * delta_x;
211 int32_t velocity_x_product_high = (int32_t)((uint64_t)velocity_x_product_wide >> 32);
212 int32_t velocity_x_product_low = (uint32_t)velocity_x_product_wide;
216 int64_t velocity_y_product_wide = (int64_t)step_scale_q12 * saved_target_delta_y;
217 int32_t velocity_y_product_high = (int32_t)((uint64_t)velocity_y_product_wide >> 32);
218 int32_t velocity_y_product_low = (uint32_t)velocity_y_product_wide;
222 int64_t velocity_z_product_wide = (int64_t)step_scale_q12 * delta_z;
223 int32_t velocity_z_product_high = (int32_t)((uint64_t)velocity_z_product_wide >> 32);
224 int32_t velocity_z_product_low = (uint32_t)velocity_z_product_wide;
283 if (ground_collision_node)
319 struct Scene_Node *render_root_after_orientation =
370 int32_t entity_index;
378 struct Entity *owner_entity =
391 int32_t remaining_distance_budget = (int32_t)motion_owner->
animation_step_q6 << 6;
397 int32_t requested_animation_tick = motion_owner->
animation_tick + tick_delta;
401 if ((uint32_t)requested_animation_tick >= (uint32_t)track_end_tick)
405 int32_t requested_tick_is_negative = (uint8_t)(requested_animation_tick < 0);
407 motion_owner->
animation_tick = (requested_tick_is_negative - 1) & track_end_tick;
409 else if ((uint32_t)requested_animation_tick > (uint32_t)track_end_tick)
411 int32_t previous_animation_tick = requested_animation_tick - tick_delta;
417 if (previous_animation_tick == track_end_tick)
424 if (!previous_animation_tick)
446 int32_t segment_distance =
450 if (segment_distance >= remaining_distance_budget)
452 int32_t segment_fraction_q12 =
459 int32_t clipped_delta_x = segment_delta.
x;
461 segment_delta.
z = clipped_delta_z;
472 int32_t clipped_animation_tick = segment_start_tick + clipped_tick_delta;
479 if ((uint32_t)clipped_animation_tick < (uint32_t)clipped_track_end_tick)
484 int32_t clipped_tick_is_negative = (uint8_t)(clipped_animation_tick < 0);
486 owner->
animation_tick = (clipped_tick_is_negative - 1) & clipped_track_end_tick;
491 if ((uint32_t)clipped_animation_tick <= (uint32_t)clipped_track_end_tick)
494 int32_t unclipped_previous_tick = clipped_animation_tick - clipped_tick_delta;
498 if (clipped_tick_delta >= 0)
500 if (unclipped_previous_tick != clipped_track_end_tick)
503 else if (unclipped_previous_tick)
513 int32_t sampled_target_y = sampled_target_pos.
y;
515 motion_owner = owner;
516 remaining_distance_budget -= segment_distance;
517 local_position->
x = sampled_target_pos.
x;
519 int32_t sampled_target_z = sampled_target_pos.
z;
521 local_position->
y = sampled_target_y;
522 local_position->
z = sampled_target_z;
527 }
while (remaining_distance_budget);
534 int32_t x = velocity->
x;
550 int32_t velocity_facing = (int32_t)(int16_t)target_facing;
551 int32_t facing_current_1 = (int32_t)facing_current;
552 int32_t facing_error = facing_current_1 - velocity_facing;
554 if (facing_current_1 != velocity_facing)
557 (uint16_t)turn_step);
614 vertical_speed = -(vertical_speed);
627 int32_t command_slot = 0;
632 if (command_cursor->
active)
634 int32_t command_opcode = (int32_t)(uint8_t)command_cursor->
opcode;
639 int32_t cleared_command_flags;
641 switch (command_opcode)
682 if (forward_speed_percent)
705 int32_t updated_behavior_flags = cleared_command_flags;
731 if (reverse_speed_percent)
744 actor->anim_tick = -((int32_t)actor->move_anim_speed);
751 int32_t updated_behavior_flags = cleared_command_flags;
768 if (command_speed_percent)
813 command_cursor = &command_cursor[1];
815 if (command_slot >= 3)
835 uint32_t updated_progress_bits;
846 if (progress_operand >= 0)
848 uint32_t candidate_progress_bits = progress_operand + previous_script_progress;
850 updated_progress_bits =
851 candidate_progress_bits >= previous_script_progress ? candidate_progress_bits : UINT32_MAX;
855 int32_t decreased_progress_bits = progress_operand + previous_script_progress;
857 updated_progress_bits = (uint32_t)previous_script_progress < (uint32_t)decreased_progress_bits ? 0 : (uint32_t)decreased_progress_bits;
875 bool reached = current_progress == threshold;
877 reached = current_progress > threshold;
879 reached = current_progress < threshold;
#define ACTOR_ROOT_MOTION_REVERSE
#define ACTOR_POSITION_FACING_EPSILON
#define ACTOR_BEHAVIOR_MOVEMENT_LOCKED
#define ACTOR_MOVE_TARGET_GROUND_HEIGHT_SLOP
#define ACTOR_ROOT_MOTION_STEP
@ ACTOR_MOVE_STEP_REVERSE
@ ACTOR_MOVE_STEP_FORWARD
#define ACTOR_BEHAVIOR_AIRBORNE
#define ACTOR_ROOT_MOTION_LATCHED
#define ACTOR_VELOCITY_FACING_EPSILON
#define ACTOR_LIFECYCLE_HIDDEN
#define ACTOR_LIFECYCLE_DISABLED
#define ACTOR_BEHAVIOR_MOVING_LEFT
#define ACTOR_ANIMATION_FRAMES_PER_SECOND
#define ACTOR_ROOT_MOTION_LEFT
#define ACTOR_FACING_TARGET_TOLERANCE
#define ACTOR_BEHAVIOR_TRAIL_OVERRIDE
#define ACTOR_BEHAVIOR_BYPASS_COLLISION
#define ACTOR_ROOT_MOTION_RIGHT
#define ACTOR_BEHAVIOR_MOVEMENT_ACTIVE
#define ACTOR_BEHAVIOR_PREPROCESSED
#define ACTOR_BEHAVIOR_COLLISION_CORRECTION
void Actor_UpdateWorldRenderPosition(struct Actor_State *actor)
int32_t Actor_TracePath(struct Entity *entity, int32_t target_selector, int32_t max_path_distance, int32_t best_path_distance, int32_t trace_flags)
void Actor_StartTransition(struct Actor_State *actor, struct Actor_MovementRecordView *record)
void Actor_ApplyEntitySlotFlags(struct Actor_State *actor)
void Actor_ReleaseAttachment(struct Actor_MovementRecordView *record)
void Actor_AdvanceRootMotionTick(struct Scene_Type1RenderOwnerView *owner, int32_t tick_delta)
void Actor_UpdateGroundOrientation(struct Actor_State *actor)
void Actor_ResetAnimationChains(struct Actor_State *actor)
void Actor_SetMovingRight(struct Actor_State *actor)
void Actor_MoveToTarget(struct Actor_State *actor, struct Math_Vec3I32 const *target_pos, int16_t facing_selector, int32_t facing_angle_degrees_q12, int32_t duration_frames)
void Actor_ApplyVerticalMovement(struct Actor_State *actor)
bool Actor_SetFacingTarget(struct Entity *entity, int32_t target_selector, int32_t angle_degrees_q12)
uint8_t Actor_PollMovementSignals(struct Actor_State *actor, int32_t max_events)
void Actor_ProcessMovementBehavior(struct Actor_State *actor)
BOOL Actor_UpdateRotationFromVelocity(struct Actor_State *actor, struct Math_Vec3I32 const *velocity, int32_t turn_step)
void Actor_ProcessSnapAndEntityUpdate(struct Actor_State *actor)
void Actor_SetMovingLeft(struct Actor_State *actor)
void Actor_ProcessMovementCommands(struct Actor_State *actor)
void Actor_ResetVelocityAndMoveToTarget(struct Entity *entity, int16_t facing_selector, int32_t facing_angle_degrees_q12, int32_t duration_q12)
void Actor_ApplySplineMovement(struct Scene_Type1RenderOwnerView *owner, struct Animation_SplineChannelVec3 *spline_track, int32_t tick_delta)
void Actor_SnapToPosition(struct Actor_State *actor)
#define ANIMATION_SPLINE_REPEAT_ENDPOINT
#define ANIMATION_SPLINE_TIME_Q6_MASK
#define ANIMATION_SPLINE_WRAP_SAMPLE_TIME
void Animation_InterpolateVec3(uint32_t frame_time, struct Animation_SplineChannelVec3 *vec3_track, struct Math_Vec3I32 *out_vec3)
@ COLLISION_NODE_ORIENTED_BOX
void Collision_UpdateActorGroundBarycentric(struct Actor_State *actor)
void Collision_ProjectPointOntoPolygonSurface(struct Collision_Node const *collision_node, struct Collision_Polygon const *contact_poly, struct Math_Vec3I32 const *world_pos, struct Math_Vec3I32 *out_world_pos)
void Collision_ResolveActorGroundContact(struct Actor_State *actor)
#define ENTITY_ANGLE_SCALE_Q12
#define ENTITY_FLAG_PAUSE_EXEMPT
#define ENTITY_INDEX_RECIPROCAL
#define ENTITY_FLAG_SCRIPT_PAUSED
#define GAME_TRANSITION_SCRIPT_PAUSED
#define Game_FrameTransitionFlags
void Math_BuildMatrixRotationY(struct Math_Matrix3x3I16 *out_matrix, struct Math_Matrix3x3I16 const *left_factor, int32_t angle)
int32_t Math_SqrtFP12(uint32_t value)
uint16_t Math_ClampAngleDelta(int16_t target_angle, int16_t current_angle, int16_t max_delta)
int16_t Math_CalculateAtan2FP12(int32_t y, int32_t x)
#define pkg_resource_current_level_data
#define PHYSICS_ANGLE_MASK
#define PHYSICS_MOVEMENT_DURATION_SCALE_Q24
#define PHYSICS_PERCENT_SCALE
#define PHYSICS_Q12_PRODUCT_HIGH_SHIFT
#define PHYSICS_FIXED_ONE
#define PHYSICS_ANIMATION_FRAME_TICKS
#define PHYSICS_FIXED_FRACTION_BITS
#define SCENE_NODE_DISABLED
void Script_SetVariableById(uint32_t progress_var_slot, int32_t progress_value)
uint8_t Signal_Poll(struct Signal_QueueEntry *event_buffer, int32_t max_events)
int32_t Script_GetVariableById(uint32_t progress_var_slot)
int32_t packed_parameters
int32_t facing_angle_degrees_q12
uint16_t move_frames_remaining
struct Math_Vec3I32 saved_velocity
struct Component_CollisionRecord * collision_records
uint8_t movement_counter_e
uint8_t movement_counter_d
struct Math_Vec3I32 move_target
struct Math_Vec3I32 velocity
struct Scene_Node ** render_node_list
struct Signal_QueueEntry movement_signals[3]
int32_t progress_comparison
struct Actor_MovementCommand movement_commands[3]
uint8_t movement_handler_index
struct Actor_State * child_actor
struct Collision_Polygon * ground_contact_polygon
struct Collision_Node * ground_collision_node
uint8_t behavior_flags_high
struct Actor_State * parent_actor
struct Math_Matrix3x3I16 rot_mat
struct Math_Vec3I32 position
struct Math_Vec3I32 velocity
int32_t packed_time_bias_and_end_time
Animation_SplineChannelFlags channel_flags
struct Actor_State * position_source_actor
struct Math_Vec3I32 path_target
struct Math_Vec3I32 * position_ptr
struct Actor * runtime_actor
struct Math_Vec3I32 path_result
struct Entity * entity_array
struct Scene_TransformNodePrefix transform
int16_t animation_step_q6