102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference | GitLab repository
Loading...
Searching...
No Matches
collision.c
Go to the documentation of this file.
1/* Recovered game implementation; original addresses identify provenance. */
15#include "pcdogs/actor/types.h"
19#include "pcdogs/camera/types.h"
26#include "pcdogs/entity/types.h"
27#include "pcdogs/game/globals.h"
28#include "pcdogs/game/types.h"
31#include "pcdogs/level/types.h"
33#include "pcdogs/math/types.h"
39#include "pcdogs/scene/types.h"
41#include <math.h>
42#include <stdarg.h>
43#include <string.h>
44
45// Original pcdogs.exe: no direct counterpart (decomp helper)
46// Computes a Q12 three-component dot product with modulo-64-bit accumulation and returns the low 32 bits after shifting.
47static int32_t Math_DotProduct3Q12(int32_t ax, int32_t ay, int32_t az, int32_t bx, int32_t by, int32_t bz)
48{
49 uint64_t sum = (uint64_t)((int64_t)ax * bx) + (uint64_t)((int64_t)ay * by) + (uint64_t)((int64_t)az * bz);
50
51 return (int32_t)(uint32_t)(sum >> PHYSICS_FIXED_FRACTION_BITS);
52}
53
54// Original pcdogs.exe: 0x40b350
55// Dispatches collision queries, condition checks, and ordinary contact responses, updating the actor's retained contacts. Its result can be a status or distance, depending on the collision-depth selector.
56int32_t Actor_ProcessCollisionResponse(struct Actor_State *actor, struct Actor_State *other_actor, struct Collision_Polygon *collision_poly, int32_t collision_depth)
57{
58 struct Player_ControllerRecordView *controller = actor->record_ptr;
59
60 if (collision_depth != COLLISION_CALLBACK_CONTACT_PROBE)
61 {
62 if (collision_depth != COLLISION_CALLBACK_DAMAGE_PROBE)
63 {
64 int32_t other_actor_type = (uint8_t)(other_actor->actor_type);
65
66 switch (other_actor_type)
67 {
71 {
73 entity_navigation_work_list_staging_buffer_ptr =
75 int32_t nav_command_count =
76 entity_navigation_work_list_staging_buffer_ptr->nav_command_count;
77
78 if (!nav_command_count || entity_navigation_work_list_staging_buffer_ptr->nav_commands[nav_command_count - 1].command_type != ACTOR_NAV_COMMAND_GEOMETRY_CONTACT || (int32_t)(uint16_t)entity_navigation_work_list_staging_buffer_ptr->nav_commands[nav_command_count - 1].target_selector_b != (int32_t)controller->owner_entity_index + 1)
81
82 int32_t behavior_flags = actor->behavior_flags;
83
84 if (ACTOR_BEHAVIOR_PREPROCESSED & behavior_flags)
85 {
86 controller->movement_param_40 = pkg_resource_current_level_data->entity_array[(int32_t)controller->owner_entity_index].param_max_speed_0;
87 controller->movement_param_4c = pkg_resource_current_level_data->entity_array[(int32_t)controller->owner_entity_index].param_max_speed_2;
88 controller->jump_grace_ticks = 0;
89 controller->jump_phase_ticks = 0;
90 controller->forced_animation_ticks = 0;
91
92 if (!(collision_poly->flags & COLLISION_POLYGON_WALL_RESPONSE) || controller->death_stage)
93 {
94 struct Actor_State *pending_ground_actor =
95 controller->pending_ground_actor;
96
97 if (pending_ground_actor && pending_ground_actor->actor_type == ACTOR_OBJECT_FORCE_EMITTER)
98 {
99 if (!((*actor->render_node_list)->traversal_flags & SCENE_NODE_DISABLED))
100 return UINT32_MAX;
101 }
102 }
103 else
104 {
105 if (!((*actor->render_node_list)->traversal_flags & SCENE_NODE_DISABLED))
106 return UINT32_MAX;
107 }
108
109 return 1;
110 }
111
112 int32_t collision_response_sign_bits;
113
114 if (collision_depth)
115 {
116 if (PHYSICS_FIXED_ONE - collision_depth <= (int32_t)controller->pending_contact_priority_q12 || (controller->attachment_ticks <= 0 && !controller->forced_animation_ticks && !(collision_poly->flags & COLLISION_POLYGON_WALL_RESPONSE)))
117 {
118 collision_response_sign_bits = -((actor->behavior_flags & ACTOR_BEHAVIOR_MOVING_LEFT ? 1 : 0));
119 collision_response_sign_bits &= ~ACTOR_COLLISION_RESPONSE_REJECT_BIT;
120
121 return collision_response_sign_bits + 1;
122 }
123 }
124 else if (controller->state_flags & ACTOR_CONTROLLER_GROUND_REACTION || PHYSICS_FIXED_ONE - collision_depth <= (int32_t)controller->pending_contact_priority_q12 || (controller->attachment_ticks <= 0 && !controller->forced_animation_ticks && !(collision_poly->flags & COLLISION_POLYGON_WALL_RESPONSE)))
125 {
126 collision_response_sign_bits = -((actor->behavior_flags & ACTOR_BEHAVIOR_MOVING_LEFT ? 1 : 0));
127 collision_response_sign_bits &= ~ACTOR_COLLISION_RESPONSE_REJECT_BIT;
128
129 return collision_response_sign_bits + 1;
130 }
131
132 struct Math_Vec3I32 delta_vec;
133
134 if (other_actor->actor_type != ACTOR_OBJECT_SCENE_OWNER || (actor->ground_collision_node == (struct Collision_Node *)other_actor && ((uint8_t)behavior_flags & (ACTOR_BEHAVIOR_AIRBORNE | ACTOR_BEHAVIOR_GROUNDED_MOTION)) != ACTOR_BEHAVIOR_AIRBORNE))
135 {
136 delta_vec.x = actor->velocity.x;
137 delta_vec.y = actor->velocity.y;
138 delta_vec.z = actor->velocity.z;
139 }
140 else
141 {
142 int32_t other_motion_y = other_actor->sub_pos.y;
143 int32_t actor_motion_y = actor->sub_pos.y;
144
145 delta_vec.x = actor->sub_pos.x - other_actor->sub_pos.x;
146
147 int32_t actor_motion_z = actor->sub_pos.z;
148
149 delta_vec.y = actor_motion_y - other_motion_y;
150 delta_vec.z = actor_motion_z - other_actor->sub_pos.z;
151 }
152
153 struct
154 {
155 struct Math_Vec3I16 normal;
156 uint16_t padding;
157 } normal_storage;
158
159 if (!Physics_CheckGroundSlopeDirection(other_actor, collision_poly, &normal_storage.normal,
160 &delta_vec))
161 {
162 collision_response_sign_bits = -((actor->behavior_flags & ACTOR_BEHAVIOR_MOVING_LEFT ? 1 : 0));
163 collision_response_sign_bits &= ~ACTOR_COLLISION_RESPONSE_REJECT_BIT;
164
165 return collision_response_sign_bits + 1;
166 }
167
168 uint16_t surface_suppresses_attachment = collision_poly->flags & COLLISION_POLYGON_WALL_RESPONSE;
169
170 if (!surface_suppresses_attachment && controller->attachment_ticks > 0 && normal_storage.normal.y > COLLISION_GROUND_NORMAL_MIN_Q12)
171 {
172 collision_response_sign_bits = -((actor->behavior_flags & ACTOR_BEHAVIOR_MOVING_LEFT ? 1 : 0));
173 collision_response_sign_bits &= ~ACTOR_COLLISION_RESPONSE_REJECT_BIT;
174
175 return collision_response_sign_bits + 1;
176 }
177
178 if (!surface_suppresses_attachment)
179 controller->pending_ground_actor = actor;
180 else
181 {
182 struct Pkg_CollisionFacePlane *face_plane;
183
184 if (controller->death_stage)
185 face_plane = collision_poly->face_plane;
186
187 if (!controller->death_stage || (int32_t)(((int32_t)face_plane->normal.z * (int32_t)other_actor->rot_mat.m12 + (int32_t)face_plane->normal.y * (int32_t)other_actor->rot_mat.m11 + (int32_t)face_plane->normal.x * (int32_t)other_actor->rot_mat.m10) & ((uint32_t)~PHYSICS_Q12_FRACTION_MASK)) <= PHYSICS_GROUND_NORMAL_THRESHOLD_Q24)
188 {
189 controller->pending_ground_actor = other_actor;
190 }
191 else
192 break;
193 }
194
195 int32_t relative_motion_y = delta_vec.y;
196
197 controller->relative_contact_velocity_q12.x = delta_vec.x;
198
199 int32_t relative_motion_z = delta_vec.z;
200
201 controller->relative_contact_velocity_q12.y = relative_motion_y;
202
203 int16_t contact_normal_x = normal_storage.normal.x;
204 int16_t contact_normal_y = normal_storage.normal.y;
205
206 controller->contact_normal_q12.x = contact_normal_x;
207 controller->contact_normal_q12.y = contact_normal_y;
208 controller->relative_contact_velocity_q12.z = relative_motion_z;
209
210 int32_t packed_contact_normal_z_padding = *(uint32_t *)((char *)&normal_storage + 4);
211
212 controller->contact_normal_q12.z = (uint16_t)packed_contact_normal_z_padding;
213 controller->reserved_1e = (uint16_t)((uint32_t)packed_contact_normal_z_padding >> 16);
214 controller->pending_contact_priority_q12 = (PHYSICS_FIXED_ONE - collision_depth);
215
216 return UINT32_MAX;
217 }
218
220 {
221 uint8_t initial_collision_class = other_actor->collision_class;
222
223 if (initial_collision_class == COLLISION_ACTOR_CLASS_CHARACTER)
224 return Actor_ProcessPuppyInteraction(actor, other_actor, collision_poly,
225 collision_depth);
226
227 if (initial_collision_class != COLLISION_ACTOR_CLASS_PROJECTILE)
228 {
229 if (initial_collision_class != COLLISION_ACTOR_CLASS_POWERUP)
230 return UINT32_MAX;
231
232 if (collision_depth <= (int32_t)((struct Actor_CollisionFractionView *)other_actor)->collision_fraction_q12)
233 {
234 ((struct Actor_CollisionFractionView *)other_actor)->collision_fraction_q12 = (uint16_t)collision_depth;
235 controller->nearest_class4_actor = other_actor;
236 }
237 }
238 else if (Component_GetDamageAmount((struct Component_ProjectileActorView *)(other_actor), NULL) > 0)
239 Audio_RegisterCollisionSoundEvent(actor, other_actor,
241
242 break;
243 }
244
246 {
247 Actor_HandleCollisionResponse(actor, other_actor, collision_poly, collision_depth);
248
249 break;
250 }
251 }
252 }
253 else if (other_actor->actor_type == ACTOR_OBJECT_FORCE_EMITTER)
254 return Actor_EvaluateCollisionConditionSelector(actor, other_actor);
255
256 return 0;
257 }
258
259 uint8_t collision_class = other_actor->collision_class;
260
261 if (collision_class == COLLISION_ACTOR_CLASS_CHARACTER)
262 {
263 if (actor->behavior_flags & ACTOR_BEHAVIOR_WORKLIST_MEMBER && pkg_resource_current_level_data->entity_array[(int32_t)(uint16_t)((const struct Actor_MovementRecordView *)other_actor->record_ptr)->entity_index].shared_ref_50)
264 Component_UpdateCollisionDetection(controller->component_records, 2, actor, other_actor,
265 NULL);
266
267 if (!controller->reaction_animation_ticks)
268 {
269 if (actor->component_count)
271
272 if (!((other_actor->behavior_flags | actor->behavior_flags) & ACTOR_BEHAVIOR_WORKLIST_MEMBER))
273 return ((int32_t)actor->collision_radius + (int32_t)actor->collision_height + (int32_t)other_actor->collision_radius + (int32_t)other_actor->collision_height) >> 1;
274
275 return UINT32_MAX;
276 }
277 }
278 else if (collision_class == COLLISION_ACTOR_CLASS_PROJECTILE && Component_CheckActorCollisionTypeAdapter((struct Component_ProjectileActorView *)(other_actor), actor))
280
281 return collision_depth;
282}
283
284// Original pcdogs.exe: 0x42e700
285// Classifies another actor against collision and team masks, returning zero, one, or minus one. Self-collision is rejected, and definition flags can downgrade a positive classification.
286int32_t Actor_CheckCollisionType(struct Actor_State *actor, struct Component_Definition *component_definition, struct Actor_State *other_actor)
287{
288 if (actor == other_actor)
289 return 0;
290
291 // Character masks depend on worklist membership. Projectile masks depend on the owner.
292 int32_t collision_class = (int32_t)other_actor->collision_class;
293
294 if (collision_class == COLLISION_ACTOR_CLASS_CHARACTER)
295 {
296 int16_t other_attachment_mode = ((const struct Player_ControllerRecordView *)other_actor->record_ptr)->death_stage;
297
298 if (other_attachment_mode != ACTOR_DEATH_ANIMATING && other_attachment_mode != ACTOR_DEATH_RESPAWN_OR_FADE)
299 {
300 Component_CollisionTargetMask collision_neutral_mask =
301 component_definition->collision_neutral_mask;
302
304 {
305 if (!(collision_neutral_mask & COMPONENT_COLLISION_CLASS2_UNFLAGGED_ACTOR))
306 return ((component_definition->collision_positive_mask & COMPONENT_COLLISION_CLASS2_UNFLAGGED_ACTOR) ? 1 : -1);
307 }
308 else if (!(collision_neutral_mask & COMPONENT_COLLISION_CLASS2_FLAGGED_ACTOR))
309 return ((component_definition->collision_positive_mask & COMPONENT_COLLISION_CLASS2_FLAGGED_ACTOR) ? 1 : -1);
310 }
311 }
312 else if (collision_class == COLLISION_ACTOR_CLASS_PROJECTILE)
313 {
314 void *record_ptr = other_actor->record_ptr;
315 void *collision_owner = *(void **)record_ptr;
316
317 if (actor != collision_owner)
318 {
319 bool definition_disables_positive_collision;
320 int32_t owner_behavior_flags;
321
322 if (collision_owner)
323 owner_behavior_flags = (uint32_t)((const struct Actor_State *)collision_owner)->behavior_flags;
324
325 if (!collision_owner || (!(owner_behavior_flags & ACTOR_BEHAVIOR_WORKLIST_MEMBER) && ((uint8_t)owner_behavior_flags & ACTOR_BEHAVIOR_GROUND_TRACKING)))
326 {
328 {
330 return -1;
331
332 definition_disables_positive_collision =
334
335 return ((definition_disables_positive_collision) ? -1 : 1);
336 }
337 }
338 else if ((owner_behavior_flags & ACTOR_BEHAVIOR_WORKLIST_MEMBER) && !(component_definition->collision_neutral_mask & COMPONENT_COLLISION_CLASS3_FLAGGED_OWNER))
339 {
341 return -1;
342
343 definition_disables_positive_collision =
345
346 return ((definition_disables_positive_collision) ? -1 : 1);
347 }
348 }
349 }
350 else if (collision_class == COLLISION_ACTOR_CLASS_POWERUP && !(component_definition->collision_neutral_mask & COMPONENT_COLLISION_POWERUP))
351 return ((component_definition->collision_positive_mask & COMPONENT_COLLISION_POWERUP) ? 1 : -1);
352
353 return 0;
354}
355
356// Original pcdogs.exe: 0x42f2a0
357// Returns zero without applying damage or changing the actor.
359{
360 (void)actor;
361 return 0;
362}
363
364// Original pcdogs.exe: 0x4353d0
365// Builds ground-aligned actor orientation, including quaternion tilt blending and child orientation when present. The contact-orientation storage is interpreted according to this path's quaternion role.
367{
368 struct Actor_State *child_actor = actor->child_actor;
369
370 // The child carries the ground rotation when present.
371 if (!child_actor)
372 child_actor = actor;
373
374 uint16_t ground_yaw = actor->facing_blend;
375 struct Math_Matrix3x3I16 *aligned_rotation = &child_actor->rot_mat;
376
377 ground_yaw += actor->facing_current;
378 Math_BuildMatrixRotationY(aligned_rotation, NULL, ground_yaw & PHYSICS_ANGLE_MASK);
379
380 struct Math_QuaternionI16 *ground_tilt_quaternion = (struct Math_QuaternionI16 *)&child_actor->contact_basis;
381 struct Math_Vec3I16 from_vec;
382 int32_t tilt_yz_product;
383 struct Math_Vec3I16 rotated_normal;
384 struct Math_Matrix3x3I16 tilt_rotation;
385
387 {
388 int16_t w = ground_tilt_quaternion->w;
389
390 if (w == PHYSICS_Q14_ONE)
391 return;
392
393 int32_t y = (int32_t)ground_tilt_quaternion->y;
394 int32_t x = (int32_t)ground_tilt_quaternion->x;
395 int32_t tilt_y_squared = y * y;
396 int32_t z = (int32_t)ground_tilt_quaternion->z;
397
398 tilt_yz_product = z * y;
399
400 int32_t tilt_xy_product = y * x;
401 int32_t tilt_w_component = (int32_t)w;
402 int32_t tilt_x_squared = x * x;
403 int32_t tilt_xz_product = z * x;
404 int32_t tilt_wx_product = tilt_w_component * x;
405 int32_t tilt_wz_product = tilt_w_component * z;
406 int32_t tilt_wy_product = tilt_w_component * y;
407
408 tilt_rotation.m00 = (int16_t)((PHYSICS_QUATERNION_DIAGONAL_HALF_Q28 - z * z - tilt_y_squared) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
409 tilt_rotation.m10 = (int16_t)((tilt_xy_product - tilt_wz_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
410 tilt_rotation.m11 = (int16_t)((PHYSICS_QUATERNION_DIAGONAL_HALF_Q28 - z * z - tilt_x_squared) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
411 tilt_rotation.m20 = (int16_t)((tilt_wy_product + tilt_xz_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
412 tilt_rotation.m21 = (int16_t)((tilt_yz_product - tilt_wx_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
413 tilt_rotation.m02 = (int16_t)((tilt_xz_product - tilt_wy_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
414 tilt_rotation.m01 = (int16_t)((tilt_wz_product + tilt_xy_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
415 tilt_rotation.m12 = (int16_t)((tilt_wx_product + tilt_yz_product) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
416 tilt_rotation.m22 = (int16_t)((PHYSICS_QUATERNION_DIAGONAL_HALF_Q28 - tilt_y_squared - tilt_x_squared) >> PHYSICS_QUATERNION_MATRIX_SHIFT);
417 Math_MulMat3x3Q12(aligned_rotation, aligned_rotation, &tilt_rotation);
418
419 return;
420 }
421
422 struct Collision_Node *ground_collision_node = actor->ground_collision_node;
423 struct Math_Vec3I16 *to_vec = &actor->ground_contact_polygon->face_plane->normal;
424
426 {
427 rotated_normal.x = (int16_t)(((int32_t)ground_collision_node->transform_matrix.m02 * (int32_t)to_vec->z + (int32_t)ground_collision_node->transform_matrix.m01 * (int32_t)to_vec->y + (int32_t)ground_collision_node->transform_matrix.m00 * (int32_t)to_vec->x) >> PHYSICS_FIXED_FRACTION_BITS);
428 rotated_normal.y = (int16_t)((
429 (int32_t)ground_collision_node->transform_matrix.m12 * (int32_t)to_vec->z + (int32_t)ground_collision_node->transform_matrix.m11 * (int32_t)to_vec->y + (int32_t)ground_collision_node->transform_matrix.m10 * (int32_t)to_vec->x) >>
431
432 int32_t rotated_normal_z_product = (int32_t)ground_collision_node->transform_matrix.m22 * (int32_t)to_vec->z + (int32_t)ground_collision_node->transform_matrix.m21 * (int32_t)to_vec->y + (int32_t)ground_collision_node->transform_matrix.m20 * (int32_t)to_vec->x;
433
434 rotated_normal.z = (int16_t)(rotated_normal_z_product >> PHYSICS_FIXED_FRACTION_BITS);
435 to_vec = &rotated_normal;
436 }
437
439 {
440 from_vec = (struct Math_Vec3I16){
441 .z = 0,
442 .x = 0,
443 .y = PHYSICS_FIXED_ONE};
444
445 Math_BuildRotationFromVectors(&from_vec, to_vec, &tilt_rotation);
446 Math_BuildQuaternionFromMatrix(&tilt_rotation, ground_tilt_quaternion);
447 }
448 else
449 *(struct Math_QuaternionI16 *)ground_tilt_quaternion = (struct Math_QuaternionI16){
450 .w = PHYSICS_Q14_ONE,
451 .z = 0,
452 .y = 0,
453 .x = 0};
454
455 int32_t behavior_flags = actor->behavior_flags;
456
457 if (behavior_flags & ACTOR_BEHAVIOR_MOVEMENT_ACTIVE)
458 {
459 if (!actor->child_actor)
460 {
461 struct Collision_Polygon *ground_contact_polygon = actor->ground_contact_polygon;
462
463 behavior_flags &= ~ACTOR_BEHAVIOR_GROUND_TILT_ENABLED;
464 actor->behavior_flags = behavior_flags;
465
467 {
468 behavior_flags |= ACTOR_BEHAVIOR_SKIP_UPDATE;
470 actor->behavior_flags = behavior_flags;
471 }
472 }
473 else if ((*(struct Scene_Node **)actor->render_node_list)->traversal_flags & SCENE_NODE_DISABLED)
474 {
475 child_actor->sub_pos = (struct Math_Vec3I32){
476 .z = 0,
477 .y = 0,
478 .x = 0};
479
480 child_actor->anim_seq_timer = 0;
481
482 memcpy((uint8_t *)ground_tilt_quaternion + 8, ground_tilt_quaternion,
483 sizeof *ground_tilt_quaternion);
484 }
485 else
487 }
488
489 if (ground_tilt_quaternion->w != PHYSICS_Q14_ONE)
490 Math_MulMat3x3Q12(aligned_rotation, aligned_rotation, &tilt_rotation);
491}
492
493// Original pcdogs.exe: 0x4356e0
494// Integrates attachments and movement, resolves and projects ground contact, dispatches collision responses, and updates orientation. The saved position baseline can advance within the routine, so final displacement need not equal total frame movement.
496{
497 struct Actor_State *integrating_actor = actor;
498 struct Collision_Polygon *ground_contact_polygon = integrating_actor->ground_contact_polygon;
499
500 if (ground_contact_polygon && g_currentGameMode == GAME_MODE_GAMEPLAY_3D && ground_contact_polygon->flags & (COLLISION_SURFACE_TRAIL_IMPACT << COLLISION_SURFACE_TRAIL_SHIFT))
501 {
502 integrating_actor->ground_contact_polygon = NULL;
503 integrating_actor->ground_collision_node = NULL;
504 }
505
506 struct Math_Vec3I32 *integrated_position = &integrating_actor->position;
507 struct Actor_State *parent_actor = integrating_actor->parent_actor;
508 int32_t integration_baseline_x = integrated_position->x;
509 int32_t integration_baseline_y = integrated_position->y;
510 int32_t integration_baseline_z = integrated_position->z;
511
512 if (parent_actor)
513 {
515 {
516 int32_t behavior_flags = integrating_actor->behavior_flags;
517
519 integrating_actor->behavior_flags = behavior_flags;
520 }
521
522 Actor_UpdateAttachmentTransform(integrating_actor);
523 }
524
525 int16_t scale_factor = integrating_actor->scale_factor;
526 struct Math_Vec3I32 out_world_pos;
527 struct Math_Vec3I32 *frame_displacement;
528
529 if (scale_factor == PHYSICS_FIXED_ONE || parent_actor)
530 {
531 int32_t position_before_motion_y = integrating_actor->position.y;
532
533 frame_displacement = &integrating_actor->sub_pos;
534
535 int32_t z = integrating_actor->position.z;
536
537 integrated_position->x += integrating_actor->sub_pos.x;
538 integrating_actor->position.y = position_before_motion_y + integrating_actor->sub_pos.y;
539 integrating_actor->position.z = z + integrating_actor->sub_pos.z;
540 }
541 else
542 {
543 frame_displacement = &integrating_actor->sub_pos;
544
545 int64_t displacement_x_product_wide = (int64_t)(int32_t)((int32_t)scale_factor) * (int32_t)(integrating_actor->sub_pos.x);
546 int32_t scaled_motion_y = integrating_actor->sub_pos.y;
547
548 out_world_pos.x = (int32_t)((uint64_t)displacement_x_product_wide >> PHYSICS_FIXED_FRACTION_BITS);
549
550 int64_t displacement_y_product_wide = (int64_t)(int32_t)((int32_t)integrating_actor->scale_factor) * (int32_t)(scaled_motion_y);
551 int32_t z_motion_scale = (int32_t)integrating_actor->scale_factor;
552
553 out_world_pos.y = (int32_t)((uint64_t)displacement_y_product_wide >> PHYSICS_FIXED_FRACTION_BITS);
554
555 int64_t displacement_z_product_wide = (int64_t)(int32_t)(z_motion_scale) * (int32_t)(integrating_actor->sub_pos.z);
556 int32_t displacement_z = (int32_t)((uint64_t)displacement_z_product_wide >> PHYSICS_FIXED_FRACTION_BITS);
557 char vertical_motion_flags = (char)integrating_actor->behavior_flags;
558
559 out_world_pos.z = displacement_z;
560
562 out_world_pos.y = integrating_actor->sub_pos.y;
563
564 int32_t position_before_scaled_y = integrating_actor->position.y;
565
566 integrated_position->x += out_world_pos.x;
567 integrating_actor->position.y = position_before_scaled_y + out_world_pos.y;
568 integrating_actor->position.z += displacement_z;
569 }
570
571 int32_t ground_query_flags = integrating_actor->behavior_flags;
572 int32_t previous_motion_flags = ground_query_flags;
573
574 ground_query_flags &= ~ACTOR_BEHAVIOR_GROUNDED_MOTION;
575
576 int32_t prior_air_ground_flags = previous_motion_flags & (ACTOR_BEHAVIOR_AIRBORNE | ACTOR_BEHAVIOR_GROUNDED_MOTION);
577
578 integrating_actor->behavior_flags = ground_query_flags;
579
580 struct Actor_State *child_for_ground_query;
581
583 ((child_for_ground_query = integrating_actor->child_actor) &&
584 !(integrating_actor->lifecycle_flags & (ACTOR_LIFECYCLE_DISABLED | ACTOR_LIFECYCLE_DESTROYING)) && !(child_for_ground_query->lifecycle_flags & ACTOR_LIFECYCLE_DISABLED)))
585 {
586 // Active, unlocked movement starts the ground query airborne.
588 {
589 ground_query_flags |= ACTOR_BEHAVIOR_AIRBORNE;
590 integrating_actor->behavior_flags = ground_query_flags;
591 }
592
593 struct Collision_Node *queried_ground_node =
594 Collision_FindActorGroundContact(integrating_actor, &integrating_actor->ground_contact_polygon);
595 struct Collision_Node *contact_node = queried_ground_node;
596
597 integrating_actor->ground_collision_node = queried_ground_node;
598
599 struct Collision_Node *saved_contact_node = contact_node;
600 int16_t flags_after_ground_query;
601
602 if (contact_node)
603 flags_after_ground_query = (int16_t)integrating_actor->behavior_flags;
604
605 bool update_ground_contact = true;
606
607 if (!contact_node || (uint8_t)flags_after_ground_query & ACTOR_BEHAVIOR_AIRBORNE)
608 {
609 out_world_pos = (struct Math_Vec3I32){
610 .x = integrated_position->x - integration_baseline_x,
611 .y = integrating_actor->position.y - integration_baseline_y,
612 .z = integrating_actor->position.z - integration_baseline_z};
613
614 int64_t displacement_x_squared_wide = (int64_t)(int32_t)(out_world_pos.x) * (int32_t)(out_world_pos.x);
615 int64_t displacement_z_squared_wide = (int64_t)(int32_t)(out_world_pos.z) * (int32_t)(out_world_pos.z);
616 int32_t horizontal_displacement_squared = ((int32_t)((uint64_t)displacement_x_squared_wide >> PHYSICS_FIXED_FRACTION_BITS)) + ((int32_t)((uint64_t)displacement_z_squared_wide >> PHYSICS_FIXED_FRACTION_BITS));
617 int64_t displacement_y_squared_wide = (int64_t)(int32_t)(out_world_pos.y) * (int32_t)(out_world_pos.y);
618
619 if (out_world_pos.y <= 0 || ((int32_t)((uint64_t)displacement_y_squared_wide >> PHYSICS_FIXED_FRACTION_BITS)) < horizontal_displacement_squared)
620 out_world_pos.y = Math_SqrtFP12(horizontal_displacement_squared);
621
622 int32_t saved_position_y = integrating_actor->position.y;
623
624 integrating_actor->position.y = integration_baseline_y + out_world_pos.y;
625
626 int32_t ground_resolution_flags = integrating_actor->behavior_flags;
627
628 if (!(ground_resolution_flags & ACTOR_BEHAVIOR_MOVEMENT_LOCKED))
629 {
630 ground_resolution_flags |= ACTOR_BEHAVIOR_AIRBORNE;
631 integrating_actor->behavior_flags = ground_resolution_flags;
632 }
633
634 Collision_ResolveActorGroundContact(integrating_actor);
635 integrating_actor->position.y = saved_position_y;
636
637 struct Collision_Node *resolved_ground_node = integrating_actor->ground_collision_node;
638
639 saved_contact_node = resolved_ground_node;
640
642 Collision_ProjectPointOntoPolygonSurface(resolved_ground_node,
643 integrating_actor->ground_contact_polygon, integrated_position, integrated_position);
644
645 contact_node = saved_contact_node;
646 }
647 else
648 {
649 update_ground_contact = integrated_position->x != integration_baseline_x ||
650 integrating_actor->position.z != integration_baseline_z || contact_node->node_type != COLLISION_NODE_ORIENTED_BOX ||
651 (flags_after_ground_query & ACTOR_BEHAVIOR_MOVEMENT_ACTIVE);
652
653 if (!update_ground_contact)
654 {
655 struct Actor_State *child_actor = integrating_actor->child_actor;
656
657 if (child_actor)
658 {
659 struct Math_Matrix3x3I16 rotation_row0_xy;
660
661 rotation_row0_xy.m00 = integrating_actor->rot_mat.m00;
662 rotation_row0_xy.m01 = integrating_actor->rot_mat.m01;
663 child_actor->rot_mat.m00 = rotation_row0_xy.m00;
664 child_actor->rot_mat.m01 = rotation_row0_xy.m01;
665
666 struct Math_Matrix3x3I16 rotation_row0_z_row1_x;
667
668 rotation_row0_z_row1_x.m02 = integrating_actor->rot_mat.m02;
669 rotation_row0_z_row1_x.m10 = integrating_actor->rot_mat.m10;
670 child_actor->rot_mat.m02 = rotation_row0_z_row1_x.m02;
671 child_actor->rot_mat.m10 = rotation_row0_z_row1_x.m10;
672
673 struct Math_Matrix3x3I16 rotation_row1_yz;
674
675 rotation_row1_yz.m11 = integrating_actor->rot_mat.m11;
676 rotation_row1_yz.m12 = integrating_actor->rot_mat.m12;
677 child_actor->rot_mat.m11 = rotation_row1_yz.m11;
678 child_actor->rot_mat.m12 = rotation_row1_yz.m12;
679
680 struct Math_Matrix3x3I16 rotation_row2_xy;
681
682 rotation_row2_xy.m20 = integrating_actor->rot_mat.m20;
683 rotation_row2_xy.m21 = integrating_actor->rot_mat.m21;
684 child_actor->rot_mat.m20 = rotation_row2_xy.m20;
685 child_actor->rot_mat.m21 = rotation_row2_xy.m21;
686 child_actor->rot_mat.m22 = integrating_actor->rot_mat.m22;
687 // The child inherits the stationary ground orientation and has no displacement.
688 integrating_actor->child_actor->sub_pos.z = 0;
689 integrating_actor->child_actor->sub_pos.y = 0;
690 integrating_actor->child_actor->sub_pos.x = 0;
691
692 if (integrating_actor->child_actor->anim_seq_timer && integrating_actor->behavior_flags_high & (ACTOR_BEHAVIOR_GROUND_TILT_ENABLED >> 8))
693 update_ground_contact = true;
694 }
695 }
696 }
697
698 if (update_ground_contact)
699 {
700 if (contact_node)
701 {
702 struct Collision_Polygon *contact_polygon =
703 integrating_actor->ground_contact_polygon;
704
706 contact_polygon, integrated_position, &out_world_pos);
707
708 int32_t collision_height_offset;
709
710 if (integrating_actor->world_render_pos.y != integration_baseline_y)
711 collision_height_offset = 0;
712 else
713 collision_height_offset = (int32_t)integrating_actor->collision_height_hi << 6;
714
715 int32_t ground_surface_y = collision_height_offset + out_world_pos.y;
716 int32_t ground_response_flags = integrating_actor->behavior_flags;
717 int32_t y = ground_surface_y;
718
719 if (!(ground_response_flags & ACTOR_BEHAVIOR_MOVEMENT_LOCKED) && !parent_actor)
720 {
721 int32_t was_airborne = ground_response_flags & ACTOR_BEHAVIOR_AIRBORNE;
722
723 if (!was_airborne || ground_surface_y + ACTOR_GROUND_HEIGHT_SLOP >= integrating_actor->position.y)
724 {
725 struct Math_Vec3I16 world_contact_normal_q12;
726
727 if (was_airborne)
728 {
729 int32_t ground_response;
730
731 if (!((uint8_t)prior_air_ground_flags & ACTOR_BEHAVIOR_GROUNDED_MOTION))
732 /* Native MOVSX at 0x435c1d sign-extends this callback index. */
733 ground_response = Actor_DefaultUpdateCallbackSlot[(int32_t)(int8_t)integrating_actor->collision_class](integrating_actor, contact_node,
734 contact_polygon, 0);
735 else
736 ground_response = PHYSICS_FIXED_ONE;
737
738 integrating_actor->position.y = ground_surface_y;
739
740 if (ground_response >= 0)
741 {
742 struct Pkg_CollisionFacePlane *contact_plane =
743 contact_polygon->face_plane;
744
745 if ((((int32_t)contact_plane->normal.y * (int32_t)contact_node->transform_matrix.m11 + (int32_t)contact_plane->normal.z * (int32_t)contact_node->transform_matrix.m12 + (int32_t)contact_plane->normal.x * (int32_t)contact_node->transform_matrix.m10) & ~PHYSICS_Q12_FRACTION_MASK) > PHYSICS_GROUND_NORMAL_THRESHOLD_Q24)
746 {
747 if (prior_air_ground_flags == ACTOR_BEHAVIOR_AIRBORNE)
748 {
749 struct Math_Vec3I16 *landing_normal_q12 =
750 &contact_plane->normal;
751
753 {
754 world_contact_normal_q12.x = (int16_t)(((int32_t)
755 contact_node->transform_matrix.m02 *
756 (int32_t)contact_plane->normal.z +
757 (int32_t)
758 contact_node->transform_matrix.m00 *
759 (int32_t)contact_plane->normal.x +
760 (int32_t)
761 contact_node->transform_matrix.m01 *
762 (int32_t)contact_plane->normal.y) >>
764
765 int32_t m22 = (int32_t)contact_node->transform_matrix.m22;
766
767 world_contact_normal_q12.y = (int16_t)((
768 (int32_t)contact_plane->normal.y * (int32_t)contact_node->transform_matrix.m11 + (int32_t)contact_plane->normal.x * (int32_t)contact_node->transform_matrix.m10 + (int32_t)contact_plane->normal.z * (int32_t)contact_node->transform_matrix.m12) >>
770 world_contact_normal_q12.z = (int16_t)((
771 m22 * (int32_t)contact_plane->normal.z + (int32_t)contact_node->transform_matrix.m20 * (int32_t)contact_plane->normal.x + (int32_t)contact_node->transform_matrix.m21 * (int32_t)contact_plane->normal.y) >>
773 landing_normal_q12 = &world_contact_normal_q12;
774 }
775
776 int32_t normal_velocity = Math_DotProduct3Q12(
777 landing_normal_q12->x, landing_normal_q12->y, landing_normal_q12->z,
778 integrating_actor->velocity.x, integrating_actor->velocity.y, integrating_actor->velocity.z);
779 struct Actor_State *landing_actor;
780
781 if (normal_velocity >= 0)
782 landing_actor = actor;
783 else
784 {
785 // Remove the inward velocity along the landing normal.
786 int64_t normal_velocity_x_product_wide = (int64_t)(int32_t)(normal_velocity) * (int32_t)((int32_t)landing_normal_q12->x);
787 int64_t normal_velocity_y_product_wide = (int64_t)(int32_t)(normal_velocity) * (int32_t)((int32_t)landing_normal_q12->y);
788 int64_t normal_velocity_z_product_wide = (int64_t)(int32_t)(normal_velocity) * (int32_t)((int32_t)landing_normal_q12->z);
789
790 integrating_actor->velocity.x -=
791 (int32_t)((uint64_t)normal_velocity_x_product_wide >> PHYSICS_FIXED_FRACTION_BITS);
792 landing_actor = actor;
793
794 int32_t tangential_velocity_z = landing_actor->velocity.z - ((int32_t)((uint64_t)normal_velocity_z_product_wide >> PHYSICS_FIXED_FRACTION_BITS));
795
796 landing_actor->velocity.y -=
797 (int32_t)((uint64_t)normal_velocity_y_product_wide >> PHYSICS_FIXED_FRACTION_BITS);
798 landing_actor->velocity.z = tangential_velocity_z;
799 }
800
801 integrating_actor = actor;
802 contact_node = saved_contact_node;
804 }
805
806 integrating_actor->behavior_flags =
807 (integrating_actor->behavior_flags & ((int32_t)((uint32_t)~ACTOR_BEHAVIOR_AIRBORNE))) | (ACTOR_BEHAVIOR_MOVEMENT_ACTIVE | ACTOR_BEHAVIOR_GROUND_BASIS_CHANGED);
808
809 if (&contact_node->transform_matrix !=
810 &integrating_actor->contact_basis)
811 {
812 integrating_actor->contact_basis.m00 =
813 contact_node->transform_matrix.m00;
814 integrating_actor->contact_basis.m01 =
815 contact_node->transform_matrix.m10;
816 integrating_actor->contact_basis.m02 =
817 contact_node->transform_matrix.m20;
818 integrating_actor->contact_basis.m10 =
819 contact_node->transform_matrix.m01;
820 integrating_actor->contact_basis.m11 =
821 contact_node->transform_matrix.m11;
822 integrating_actor->contact_basis.m12 =
823 contact_node->transform_matrix.m21;
824 integrating_actor->contact_basis.m20 =
825 contact_node->transform_matrix.m02;
826 integrating_actor->contact_basis.m21 =
827 contact_node->transform_matrix.m12;
828 integrating_actor->contact_basis.m22 =
829 contact_node->transform_matrix.m22;
830 }
831 else
832 {
833 int16_t transposed_basis_component = integrating_actor->contact_basis.m01;
834
835 integrating_actor->contact_basis.m01 =
836 contact_node->transform_matrix.m10;
837 integrating_actor->contact_basis.m10 = transposed_basis_component;
838 transposed_basis_component = integrating_actor->contact_basis.m02;
839 integrating_actor->contact_basis.m02 =
840 contact_node->transform_matrix.m20;
841 integrating_actor->contact_basis.m20 = transposed_basis_component;
842 transposed_basis_component = integrating_actor->contact_basis.m12;
843 integrating_actor->contact_basis.m12 =
844 contact_node->transform_matrix.m21;
845 integrating_actor->contact_basis.m21 = transposed_basis_component;
846 }
847 }
848 }
849 }
850 else if (contact_node->node_type == COLLISION_NODE_ORIENTED_BOX || integrating_actor->scale_factor != PHYSICS_FIXED_ONE || ground_response_flags & (ACTOR_BEHAVIOR_MOVEMENT_ACTIVE | ACTOR_BEHAVIOR_COLLISION_CORRECTION) || integrating_actor->velocity.x || integrating_actor->velocity.y || integrating_actor->velocity.z)
851 {
852 if (ground_response_flags & ACTOR_BEHAVIOR_MOVEMENT_ACTIVE)
853 {
854 struct Math_Vec3I16 *local_face_normal_q12 =
855 &contact_polygon->face_plane->normal;
856 struct Math_Vec3I16 *ground_normal_q12 = local_face_normal_q12;
857
859 {
860 world_contact_normal_q12.x = (int16_t)((
861 (int32_t)contact_node->transform_matrix.m02 * (int32_t)local_face_normal_q12->z +
862 (int32_t)contact_node->transform_matrix.m00 * (int32_t)local_face_normal_q12->x +
863 (int32_t)contact_node->transform_matrix.m01 * (int32_t)local_face_normal_q12->y) >>
865 world_contact_normal_q12.y = (int16_t)((
866 (int32_t)contact_node->transform_matrix.m12 * (int32_t)local_face_normal_q12->z +
867 (int32_t)contact_node->transform_matrix.m10 * (int32_t)local_face_normal_q12->x +
868 (int32_t)contact_node->transform_matrix.m11 * (int32_t)local_face_normal_q12->y) >>
870 world_contact_normal_q12.z = (int16_t)((
871 (int32_t)contact_node->transform_matrix.m22 * (int32_t)local_face_normal_q12->z +
872 (int32_t)contact_node->transform_matrix.m20 * (int32_t)local_face_normal_q12->x +
873 (int32_t)contact_node->transform_matrix.m21 * (int32_t)local_face_normal_q12->y) >>
875 ground_normal_q12 = &world_contact_normal_q12;
876 }
877
879 ground_normal_q12->x, ground_normal_q12->y, ground_normal_q12->z,
880 integrating_actor->velocity.x, integrating_actor->velocity.y, integrating_actor->velocity.z) > ACTOR_GROUND_DETACH_SPEED)
881 {
882 y = actor->position.y;
884 }
885
886 ground_surface_y = y;
887 integrating_actor = actor;
888 contact_node = saved_contact_node;
889 }
890
891 integrating_actor->position.y = ground_surface_y;
892 }
893 else
894 {
895 integration_baseline_x = frame_displacement->x + integrated_position->x;
896 integration_baseline_y = integrating_actor->sub_pos.y + integrating_actor->position.y;
897 integration_baseline_z = integrating_actor->sub_pos.z + integrating_actor->position.z;
898 }
899 }
900 }
901
902 if ((uint8_t)prior_air_ground_flags & ACTOR_BEHAVIOR_GROUNDED_MOTION)
903 {
904 int32_t ground_detach_flags = integrating_actor->behavior_flags;
905 struct Pkg_CollisionFacePlane *face_plane;
906
907 if (!((uint8_t)ground_detach_flags & ACTOR_BEHAVIOR_AIRBORNE))
908 face_plane = contact_polygon->face_plane;
909
910 if ((uint8_t)ground_detach_flags & ACTOR_BEHAVIOR_AIRBORNE || (((int32_t)face_plane->normal.z * (int32_t)contact_node->transform_matrix.m12 + (int32_t)face_plane->normal.y * (int32_t)contact_node->transform_matrix.m11 + (int32_t)face_plane->normal.x * (int32_t)contact_node->transform_matrix.m10) & ~PHYSICS_Q12_FRACTION_MASK) <= PHYSICS_GROUND_NORMAL_THRESHOLD_Q24)
911 {
912 int16_t facing_current = integrating_actor->facing_current;
913 int32_t facing_target = (int32_t)integrating_actor->facing_target;
914 int32_t current_yaw = (int32_t)facing_current;
915 int32_t facing_delta_or_yaw = current_yaw - facing_target;
916
917 if (current_yaw == facing_target)
918 {
919 facing_delta_or_yaw = (integrating_actor->facing_blend + facing_current) & PHYSICS_ANGLE_MASK;
920 integrating_actor->facing_target = (uint16_t)facing_delta_or_yaw;
921 }
922
923 uint16_t blended_facing = integrating_actor->facing_blend;
924
925 integrating_actor->facing_blend = PHYSICS_FIXED_ONE;
926 blended_facing += facing_current;
927 integrating_actor->facing_current = blended_facing & PHYSICS_ANGLE_MASK;
928 integrating_actor->behavior_flags = ground_detach_flags | (ACTOR_BEHAVIOR_AIRBORNE | ACTOR_BEHAVIOR_MOVEMENT_ACTIVE);
929 integrating_actor->velocity.x = frame_displacement->x;
930 integrating_actor->velocity.y = frame_displacement->y;
931 integrating_actor->velocity.z = frame_displacement->z;
932 }
933 }
934
935 struct Actor_State *contact_child = integrating_actor->child_actor;
936 struct Actor_State *orientation_child;
937
938 if (contact_child)
939 {
940 contact_child->sub_pos.x = out_world_pos.x - contact_child->position.x;
941
942 struct Actor_State *child_for_y_displacement = integrating_actor->child_actor;
943
944 child_for_y_displacement->sub_pos.y = out_world_pos.y - child_for_y_displacement->position.y;
945
946 struct Actor_State *child_for_z_displacement = integrating_actor->child_actor;
947
948 child_for_z_displacement->sub_pos.z = out_world_pos.z - child_for_z_displacement->position.z;
949 integrating_actor->child_actor->position = out_world_pos;
950 orientation_child = integrating_actor->child_actor;
951 }
952
953 if (!contact_child || !orientation_child->visual_scale.x)
954 {
956 Actor_UpdateGroundOrientation(integrating_actor);
957 }
958 else if (orientation_child->visual_scale.y || integrating_actor->behavior_flags_high & ((ACTOR_BEHAVIOR_MOVEMENT_ACTIVE | ACTOR_BEHAVIOR_GROUND_TILT_ENABLED) >> 8))
959 Actor_UpdateGroundOrientation(integrating_actor);
960 }
961 }
962 }
963
964 int32_t frame_displacement_x = integrated_position->x - integration_baseline_x;
965 int32_t final_position_z = integrating_actor->position.z;
966
967 integrating_actor->sub_pos.y = integrating_actor->position.y - integration_baseline_y;
968 frame_displacement->x = frame_displacement_x;
969 integrating_actor->sub_pos.z = final_position_z - integration_baseline_z;
970
971 uint8_t transition_phase = integrating_actor->transition_phase;
972
974 (&g_actorPhaseCallback0)[(int32_t)transition_phase](integrating_actor);
975
976 if (!parent_actor)
977 {
978 int32_t barycentric_update_flags = integrating_actor->behavior_flags;
979
980 if (!(barycentric_update_flags & (ACTOR_BEHAVIOR_AIRBORNE | ACTOR_BEHAVIOR_MOVEMENT_LOCKED)) && integrating_actor->ground_collision_node->node_type != COLLISION_NODE_ORIENTED_BOX && (integrating_actor->scale_factor < PHYSICS_FIXED_ONE || barycentric_update_flags & (ACTOR_BEHAVIOR_MOVEMENT_ACTIVE | ACTOR_BEHAVIOR_COLLISION_CORRECTION) || integrating_actor->velocity.x || integrating_actor->velocity.y || integrating_actor->velocity.z))
982 }
983 else
984 {
985 int32_t motion_before_parent_y = integrating_actor->sub_pos.y;
986
987 frame_displacement->x -= parent_actor->sub_pos.x;
988 integrating_actor->sub_pos.y = motion_before_parent_y - parent_actor->sub_pos.y;
989 integrating_actor->sub_pos.z -= parent_actor->sub_pos.z;
990 }
991
992 int32_t end_of_frame_flags = integrating_actor->behavior_flags;
993
994 end_of_frame_flags &= ~ACTOR_BEHAVIOR_PREPROCESSED;
995 integrating_actor->behavior_flags = end_of_frame_flags;
996 Model_AdvanceAnimation(integrating_actor);
997}
998
999// Original pcdogs.exe: 0x4364d0
1000// Evaluates the selected movement, contact, input, camera, or frame condition and returns zero or minus one.
1001int32_t Actor_EvaluateCollisionConditionSelector(struct Actor_State *actor, struct Actor_State *other_actor)
1002{
1003 uint8_t render_layer = other_actor->render_layer;
1004 void *record_ptr = actor->record_ptr;
1005 int32_t subtype_or_attachment_bits = (int32_t)(int8_t)render_layer - ACTOR_CONTACT_RESPONSE_SLOT_0;
1006
1007 if ((uint32_t)subtype_or_attachment_bits < ACTOR_CONDITION_LAYER_COUNT)
1008 {
1009 int32_t condition_subtype = (uint8_t)(Actor_CheckCollisionConditions_ConditionSubtypeIndexTable[subtype_or_attachment_bits]);
1010
1011 // The contact layer selects a fixed condition or falls through to the attachment flags.
1012 switch (condition_subtype)
1013 {
1015 {
1016 return UINT32_MAX;
1017 break;
1018 }
1019
1021 {
1022 return (((uint32_t)g_frameCounter < ((const struct Player_ControllerRecordView *)record_ptr)->hazard_end_frame) ? 0 : -1);
1023 break;
1024 }
1025
1027 {
1028 struct Level_Data *current_level = pkg_resource_current_level_data;
1029 int32_t current_entity_index = (uint16_t)(current_level->current_entity_index);
1030
1031 if ((int32_t)((const struct Player_ControllerRecordView *)record_ptr)->owner_entity_index != current_entity_index)
1032 return 0;
1033
1034 void *camera_owner_record = ((const struct Player_ControllerRecordView *)record_ptr)->camera_override_node;
1035 struct Pkg_CameraDef *cam_default;
1036 int32_t active_camera_index;
1037 struct Mesh_RuntimeVertex *requested_camera_index_bits;
1038
1039 if (camera_owner_record)
1040 {
1041 active_camera_index = ((const struct Camera_DefinitionOverrideNodeView *)camera_owner_record)->camera_definition_index;
1042 cam_default = current_level->cam_default;
1043 requested_camera_index_bits = other_actor->runtime_vertex_array;
1044 }
1045
1046 return ((!camera_owner_record || (cam_default[(int32_t)requested_camera_index_bits].camera_type & (CAMERA_DEFINITION_MODE_MASK << 4)) >= (cam_default[active_camera_index].camera_type & (CAMERA_DEFINITION_MODE_MASK << 4))) ? -1 : 0);
1047 break;
1048 }
1049
1051 {
1052 break;
1053 }
1054
1055 default:
1056 /* The immutable native table contains only selectors 0..3. */
1057 __builtin_unreachable();
1058 }
1059 }
1060
1061 if (render_layer > ACTOR_INPUT_CONTACT_LAYER_MAX)
1062 return 0;
1063
1064 uint8_t attachment_condition_flags = other_actor->attach_slot_index;
1065
1067 return 0;
1068
1069 int32_t input_condition_selector = attachment_condition_flags >> 3 & ACTOR_CONTACT_INPUT_SELECTOR_MASK;
1070
1071 if (!input_condition_selector)
1072 return UINT32_MAX;
1073
1074 if (input_condition_selector == ACTOR_INPUT_CONDITION_MOVING)
1075 {
1076 return ((actor->velocity.x || actor->velocity.y || actor->velocity.z) ? -1 : 0);
1077 }
1078
1080 {
1081 int32_t input_source_index = (uint8_t)(((const struct Player_ControllerRecordView *)record_ptr)->input_source_index);
1082 int32_t button_bits = g_inputStateCurrentP1[input_source_index].button_bits;
1083
1085 switch (input_condition_selector)
1086 {
1088 {
1089 return -(((uint8_t)button_bits & INPUT_BUTTON_ACTION_1 ? 1 : 0));
1090 break;
1091 }
1092
1094 {
1095 return -(((uint8_t)button_bits & INPUT_BUTTON_ACTION_2 ? 1 : 0));
1096 break;
1097 }
1098
1100 {
1101 return -(((uint8_t)button_bits & INPUT_BUTTON_ACTION_3 ? 1 : 0));
1102 break;
1103 }
1104
1106 {
1107 return -(((uint8_t)button_bits & INPUT_BUTTON_CONFIRM ? 1 : 0));
1108 break;
1109 }
1110
1112 {
1113 return -(((uint8_t)button_bits & INPUT_BUTTON_LEFT ? 1 : 0));
1114 break;
1115 }
1116
1118 {
1119 return -(((uint8_t)button_bits & INPUT_BUTTON_RIGHT ? 1 : 0));
1120 break;
1121 }
1122
1124 {
1125 return -(((uint8_t)button_bits & INPUT_BUTTON_UP ? 1 : 0));
1126 break;
1127 }
1128
1130 {
1131 return -(((uint8_t)button_bits & INPUT_BUTTON_DOWN ? 1 : 0));
1132 break;
1133 }
1134 }
1135 }
1136
1137 return 0;
1138}
1139
1140// Original pcdogs.exe: 0x4366d0
1141// Records deferred collision reactions or applies the selected immediate response. Contact precedence can replace the retained actor while preserving an earlier contact vector and normal.
1142void Actor_HandleCollisionResponse(struct Actor_State *actor, struct Actor_State *other_actor, struct Collision_Polygon *collision_poly, int32_t collision_slot)
1143{
1144 int32_t render_layer = (int32_t)other_actor->render_layer;
1145 // Moving platforms retain relative motion and a contact normal for the next ground response.
1146 struct Player_ControllerRecordView *controller_record = actor->record_ptr;
1147
1148 if ((uint32_t)(render_layer - ACTOR_CONTACT_RESPONSE_SLOT_0) > 6u)
1149 {
1150 Actor_ResetChainState(other_actor, collision_slot);
1151
1152 return;
1153 }
1154
1155 switch (render_layer)
1156 {
1163 {
1164 controller_record->collision_response_slot_bits[render_layer - ACTOR_CONTACT_RESPONSE_SLOT_0] =
1165 (uint32_t)(uintptr_t)(other_actor);
1166
1167 break;
1168 }
1169
1171 {
1173 {
1175 (!controller_record->jump_phase_ticks && actor->sub_pos.y <= 0))
1176 {
1177 controller_record->pending_ground_actor = other_actor;
1178 controller_record->relative_contact_velocity_q12.x =
1179 actor->sub_pos.x - other_actor->sub_pos.x;
1180 controller_record->relative_contact_velocity_q12.y =
1181 actor->sub_pos.y - other_actor->sub_pos.y;
1182 controller_record->relative_contact_velocity_q12.z =
1183 actor->sub_pos.z - other_actor->sub_pos.z;
1184
1185 if (!collision_slot || !collision_poly)
1186 {
1187 controller_record->contact_normal_q12 = (struct Math_Vec3I16){
1188 .z = 0,
1189 .x = 0,
1190 .y = PHYSICS_FIXED_ONE};
1191
1192 return;
1193 }
1194
1195 struct Pkg_CollisionFacePlane *face_plane = collision_poly->face_plane;
1196
1197 controller_record->contact_normal_q12.x = (int16_t)((
1198 (int32_t)face_plane->normal.z * (int32_t)other_actor->rot_mat.m02 + (int32_t)face_plane->normal.y * (int32_t)other_actor->rot_mat.m01 + (int32_t)face_plane->normal.x * (int32_t)other_actor->rot_mat.m00) >>
1200
1201 struct Pkg_CollisionFacePlane *contact_plane = collision_poly->face_plane;
1202
1203 controller_record->contact_normal_q12.y = (int16_t)((
1204 (int32_t)contact_plane->normal.z * (int32_t)other_actor->rot_mat.m12 + (int32_t)contact_plane->normal.y * (int32_t)other_actor->rot_mat.m11 + (int32_t)contact_plane->normal.x * (int32_t)other_actor->rot_mat.m10) >>
1206
1207 struct Pkg_CollisionFacePlane *face_plane_2 = collision_poly->face_plane;
1208
1209 controller_record->contact_normal_q12.z = (int16_t)((
1210 (int32_t)face_plane_2->normal.z * (int32_t)other_actor->rot_mat.m22 + (int32_t)face_plane_2->normal.y * (int32_t)other_actor->rot_mat.m21 + (int32_t)face_plane_2->normal.x * (int32_t)other_actor->rot_mat.m20) >>
1212
1213 return;
1214 }
1215 }
1216 else
1217 {
1218 struct Actor_State *previous_response_actor =
1219 controller_record->pending_ground_actor;
1220
1221 if (previous_response_actor && previous_response_actor->actor_type <= 2)
1222 controller_record->pending_ground_actor = other_actor;
1223 }
1224
1225 break;
1226 }
1227 }
1228}
1229
1230// Original pcdogs.exe: 0x437880
1231// Accumulates vertical movement. Positive movement marks the actor airborne, while nonpositive movement resets a negative jump-phase counter.
1232void Actor_UpdateGroundedState(struct Actor_State *actor, struct Player_ControllerRecordView *record, int32_t vertical_delta, int32_t *inout_vertical_accum)
1233{
1234 *(uint32_t *)inout_vertical_accum += vertical_delta;
1235
1236 char jump_phase_ticks = record->jump_phase_ticks;
1237
1238 if (vertical_delta <= 0)
1239 {
1240 if (jump_phase_ticks < 0)
1241 record->jump_phase_ticks = 0;
1242
1243 return;
1244 }
1245
1246 if (!jump_phase_ticks)
1247 record->jump_phase_ticks = UINT8_MAX;
1248
1250}
1251
1252// Original pcdogs.exe: 0x437bf0
1253// Processes damage cooldowns and retained hazard contacts, applying damage and knockback. The result is a full signed damage value even when a caller later consumes only its low word.
1255{
1256 uint16_t reaction_animation_ticks = record->reaction_animation_ticks;
1257
1258 if (reaction_animation_ticks)
1259 record->reaction_animation_ticks = reaction_animation_ticks - 1;
1260
1261 struct Actor_State *damage_actor = actor;
1262
1263 if (reaction_animation_ticks == 1)
1265
1266 int32_t health_delta = 0;
1267 struct Actor_State *damage_contact_actor = Collision_GetValidCollisionTarget(damage_actor, 1);
1268
1269 if (!damage_contact_actor && !damage_actor->collision_class)
1270 return 0;
1271
1272 int32_t damage = 0;
1273
1274 if (damage_contact_actor)
1275 {
1277
1278 uint16_t contact_damage_amount = damage_contact_actor->chain_timer;
1279 uint16_t contact_chain_state = damage_contact_actor->chain_state;
1280
1281 health_delta = -(contact_damage_amount);
1282 record->hazard_end_frame = contact_chain_state + g_frameCounter;
1283 }
1284
1285 struct Actor_State *powerup_actor = Collision_GetValidCollisionTarget(damage_actor, 7);
1286
1287 if (powerup_actor && powerup_actor->scale_factor <= damage_actor->scale_factor)
1288 Powerup_HandleCollection(powerup_actor, damage_actor);
1289
1290 struct Player_HazardContactView *hazard_contact = record->hazard_contacts;
1291 int32_t contacts_remaining = 4;
1292 struct Player_HazardContactView *hazard_contact_cursor = hazard_contact;
1293 struct Math_Vec3I32 *impulse_direction = &hazard_contact->impulse_direction;
1294 bool has_more_contacts;
1295
1296 do
1297 {
1298 if ((int32_t)hazard_contact->frame == g_frameCounter)
1299 {
1300 struct Actor_State *hazard_actor = hazard_contact->actor;
1301
1302 if (hazard_actor)
1303 {
1304 uint8_t collision_class = hazard_actor->collision_class;
1305
1306 if (collision_class && collision_class == COLLISION_ACTOR_CLASS_PROJECTILE && Actor_CheckAnimationTrigger(hazard_actor, damage_actor) && Navigation_QueueDamageResponse(damage_actor, (struct Component_Instance *)hazard_actor))
1307 {
1308 health_delta -= Component_GetDamageAmount((struct Component_ProjectileActorView *)hazard_actor, NULL);
1309
1310 uint32_t packed_speed_range = Component_GetSpeedRange(hazard_actor);
1311 int32_t base_impulse_speed = (int32_t)(int16_t)packed_speed_range;
1312
1313 damage += (int32_t)(int16_t)(packed_speed_range >> 0x10);
1314
1315 int32_t weighted_impulse_speed = base_impulse_speed;
1316
1317 if (base_impulse_speed)
1318 {
1319 int32_t collision_weight = record->collision_weight;
1320
1321 if (collision_weight > PHYSICS_FIXED_ONE)
1322 weighted_impulse_speed =
1323 ((int64_t)weighted_impulse_speed * PHYSICS_FIXED_ONE) / collision_weight;
1324
1325 int64_t impulse_x_squared_wide = (int64_t)impulse_direction->x * impulse_direction->x;
1326 int64_t impulse_y_squared_wide = (int64_t)impulse_direction->y * impulse_direction->y;
1327 int64_t impulse_z_squared_wide = (int64_t)impulse_direction->z * impulse_direction->z;
1328 int32_t impulse_direction_length = Math_SqrtFP12(((int32_t)((int64_t)((uint64_t)impulse_z_squared_wide + (uint64_t)impulse_x_squared_wide + (uint64_t)impulse_y_squared_wide) >> PHYSICS_FIXED_FRACTION_BITS)));
1329 int32_t impulse_z;
1330 int32_t impulse_x;
1331 int32_t impulse_y;
1332
1333 if (impulse_direction_length)
1334 {
1335 int32_t impulse_speed_q16 = weighted_impulse_speed << 4;
1336 int32_t impulse_scale_q12 = ((int64_t)impulse_speed_q16 * PHYSICS_FIXED_ONE) / impulse_direction_length;
1337 int64_t impulse_x_product_wide = (int64_t)impulse_scale_q12 * impulse_direction->x;
1338
1339 impulse_x = ((int32_t)((uint64_t)impulse_x_product_wide >> PHYSICS_FIXED_FRACTION_BITS)) >> 4;
1340
1341 int64_t impulse_y_product_wide = (int64_t)impulse_scale_q12 * impulse_direction->y;
1342
1343 impulse_y = ((int32_t)((uint64_t)impulse_y_product_wide >> PHYSICS_FIXED_FRACTION_BITS)) >> 4;
1344
1345 int64_t impulse_z_product_wide = (int64_t)impulse_scale_q12 * impulse_direction->z;
1346
1347 impulse_z = ((int32_t)((uint64_t)impulse_z_product_wide >> PHYSICS_FIXED_FRACTION_BITS)) >> 4;
1348 }
1349 else
1350 {
1351 impulse_z = 0;
1352 impulse_y = 0;
1353 impulse_x = 0;
1354 }
1355
1356 record->queued_impulse_q12 = (struct Math_Vec3I32){
1357 .x = record->queued_impulse_q12.x + impulse_x,
1358 .y = record->queued_impulse_q12.y + impulse_y,
1359 .z = record->queued_impulse_q12.z + impulse_z};
1360
1361 damage_actor = actor;
1362 }
1363 }
1364 }
1365 }
1366
1367 hazard_contact = &hazard_contact_cursor[1];
1368 has_more_contacts = contacts_remaining != 1;
1369 hazard_contact_cursor = hazard_contact;
1370 impulse_direction = &hazard_contact->impulse_direction;
1371 contacts_remaining -= 1;
1372 } while (has_more_contacts);
1373
1374 if (!health_delta || record->reaction_animation_ticks)
1375 return health_delta;
1376
1378
1379 if (damage)
1380 Actor_ApplyDamageScaling(damage_actor, record, damage);
1381
1382 return health_delta;
1383}
1384
1385// Original pcdogs.exe: 0x437f20
1386// Initializes permitted damage-response parameters, divides damage by collision weight above Q12 one, and scales the two response strengths by the resulting damage.
1387void Actor_ApplyDamageScaling(struct Actor_State *actor, struct Player_ControllerRecordView *record, int32_t damage)
1388{
1390 {
1391 memcpy(&record->ground_jump_velocity,
1392 "\x00\x30\x00\x00\x00\x60\x00\x00\x34\xfb\xff\xff\x00\x60\x00\x00\x00\x80\xff\xff\x00\x20"
1393 "\x00\x00\x00\x20\x00\x00",
1394 0x1c);
1395 record->param_accel_1 = 0;
1396 record->param_accel_2 = 0;
1399 }
1400
1401 int32_t collision_weight = record->collision_weight;
1402
1403 if (collision_weight > PHYSICS_FIXED_ONE)
1404 damage = ((int64_t)damage * PHYSICS_FIXED_ONE) / collision_weight;
1405
1406 int32_t unscaled_record_parameter_c8 = record->param_C8;
1407
1408 record->ground_jump_velocity = (int32_t)((uint64_t)(((int64_t)(damage)*record->ground_jump_velocity)) >> PHYSICS_FIXED_FRACTION_BITS);
1409 record->param_C8 = (int32_t)((uint64_t)(((int64_t)(damage)*unscaled_record_parameter_c8)) >> PHYSICS_FIXED_FRACTION_BITS);
1410}
1411
1412// Original pcdogs.exe: 0x43ae00
1413// Prepends the actor to the global collision list.
void Actor_AddToCollisionList(struct Actor_State *actor)
Definition collision.c:1414
void Actor_IntegrateMovementAndCollision(struct Actor_State *actor)
Definition collision.c:495
void Actor_ApplyDamageScaling(struct Actor_State *actor, struct Player_ControllerRecordView *record, int32_t damage)
Definition collision.c:1387
int32_t Actor_EvaluateCollisionConditionSelector(struct Actor_State *actor, struct Actor_State *other_actor)
Definition collision.c:1001
int32_t Actor_CheckCollisionType(struct Actor_State *actor, struct Component_Definition *component_definition, struct Actor_State *other_actor)
Definition collision.c:286
int32_t Actor_ProcessHazardsAndDamage(struct Actor_State *actor, struct Player_ControllerRecordView *record)
Definition collision.c:1254
int32_t Actor_HandleNullDamage(struct Actor_State *actor)
Definition collision.c:358
static int32_t Math_DotProduct3Q12(int32_t ax, int32_t ay, int32_t az, int32_t bx, int32_t by, int32_t bz)
Definition collision.c:47
void Actor_UpdateGroundedState(struct Actor_State *actor, struct Player_ControllerRecordView *record, int32_t vertical_delta, int32_t *inout_vertical_accum)
Definition collision.c:1232
void Actor_UpdateGroundOrientation(struct Actor_State *actor)
Definition collision.c:366
void Actor_HandleCollisionResponse(struct Actor_State *actor, struct Actor_State *other_actor, struct Collision_Polygon *collision_poly, int32_t collision_slot)
Definition collision.c:1142
int32_t Actor_ProcessCollisionResponse(struct Actor_State *actor, struct Actor_State *other_actor, struct Collision_Polygon *collision_poly, int32_t collision_depth)
Definition collision.c:56
@ ACTOR_INPUT_CONDITION_ACTION_1
Definition constants.h:177
@ ACTOR_INPUT_CONDITION_RIGHT
Definition constants.h:182
@ ACTOR_INPUT_CONDITION_ACTION_2
Definition constants.h:178
@ ACTOR_INPUT_CONDITION_DOWN
Definition constants.h:184
@ ACTOR_INPUT_CONDITION_CONFIRM
Definition constants.h:180
@ ACTOR_INPUT_CONDITION_MOVING
Definition constants.h:176
@ ACTOR_INPUT_CONDITION_LEFT
Definition constants.h:181
@ ACTOR_INPUT_CONDITION_ACTION_3
Definition constants.h:179
@ ACTOR_INPUT_CONDITION_UP
Definition constants.h:183
#define ACTOR_BEHAVIOR_SKIP_UPDATE
Definition constants.h:7
#define ACTOR_CONTACT_INPUT_SELECTOR_MASK
Definition constants.h:82
#define ACTOR_COLLISION_RESPONSE_REJECT_BIT
Definition constants.h:83
#define ACTOR_BEHAVIOR_MOVEMENT_LOCKED
Definition constants.h:16
#define ACTOR_CONTACT_DEFAULT_IMPULSE
Definition constants.h:216
#define ACTOR_GROUND_ALIGNMENT_NEAR_ONE
Definition constants.h:214
#define ACTOR_GROUND_DETACH_SPEED
Definition constants.h:215
#define ACTOR_COLLISION_COMPONENT_QUERY_RADIUS
Definition constants.h:219
#define ACTOR_INPUT_CONTACT_LAYER_MAX
Definition constants.h:246
#define ACTOR_BEHAVIOR_AIRBORNE
Definition constants.h:13
#define ACTOR_BEHAVIOR_GROUND_BASIS_CHANGED
Definition constants.h:32
#define ACTOR_DAMAGE_ACCELERATION_PRIMARY
Definition constants.h:217
@ ACTOR_CONDITION_ALWAYS
Definition constants.h:195
@ ACTOR_CONDITION_HAZARD_TIMER_EXPIRED
Definition constants.h:196
@ ACTOR_CONDITION_INPUT_OR_CONTACT
Definition constants.h:198
@ ACTOR_CONDITION_CAMERA_PRIORITY
Definition constants.h:197
#define ACTOR_CHILD_TILT_BLEND_TICKS
Definition constants.h:212
#define ACTOR_BEHAVIOR_SKIP_ANIMATION
Definition constants.h:11
#define ACTOR_LIFECYCLE_DISABLED
Definition constants.h:39
#define ACTOR_BEHAVIOR_GROUND_TILT_ENABLED
Definition constants.h:21
#define ACTOR_BEHAVIOR_GROUND_TRACKING
Definition constants.h:12
#define ACTOR_CONDITION_LAYER_COUNT
Definition constants.h:247
#define ACTOR_CONTROLLER_GROUND_REACTION
Definition constants.h:51
#define ACTOR_BEHAVIOR_WORKLIST_MEMBER
Definition constants.h:34
@ ACTOR_DEATH_ANIMATING
Definition constants.h:133
@ ACTOR_DEATH_RESPAWN_OR_FADE
Definition constants.h:135
#define ACTOR_BEHAVIOR_MOVING_LEFT
Definition constants.h:17
#define ACTOR_GROUND_HEIGHT_SLOP
Definition constants.h:213
#define ACTOR_LIFECYCLE_DESTROYING
Definition constants.h:43
@ ACTOR_NAV_COMMAND_GEOMETRY_CONTACT
Definition constants.h:260
#define ACTOR_DAMAGE_ACCELERATION_SECONDARY
Definition constants.h:218
#define ACTOR_BEHAVIOR_GROUNDED_MOTION
Definition constants.h:14
#define ACTOR_ATTACHMENT_SUPPRESS_PLATFORM_CONTACT
Definition constants.h:48
#define ACTOR_COLLISION_AUDIO_COOLDOWN_FRAMES
Definition constants.h:201
@ ACTOR_OBJECT_RUNTIME
Definition constants.h:143
@ ACTOR_OBJECT_STATIC_COLLISION
Definition constants.h:142
@ ACTOR_OBJECT_UNTYPED
Definition constants.h:140
@ ACTOR_OBJECT_SCENE_OWNER
Definition constants.h:141
@ ACTOR_OBJECT_FORCE_EMITTER
Definition constants.h:144
@ ACTOR_CONTACT_CAMERA_OVERRIDE
Definition constants.h:233
@ ACTOR_CONTACT_RESPONSE_SLOT_2
Definition constants.h:229
@ ACTOR_CONTACT_MOVING_PLATFORM
Definition constants.h:232
@ ACTOR_CONTACT_RESPONSE_SLOT_3
Definition constants.h:230
@ ACTOR_CONTACT_RESPONSE_SLOT_4
Definition constants.h:231
@ ACTOR_CONTACT_TIMED_DAMAGE
Definition constants.h:228
@ ACTOR_CONTACT_RESPONSE_SLOT_0
Definition constants.h:227
#define ACTOR_BEHAVIOR_BYPASS_COLLISION
Definition constants.h:18
#define ACTOR_CONTACT_REQUIRES_JUMP_SURFACE
Definition constants.h:81
#define ACTOR_BEHAVIOR_MOVEMENT_ACTIVE
Definition constants.h:19
#define ACTOR_REACTION_ANIMATION_TICKS
Definition constants.h:91
#define ACTOR_BEHAVIOR_PREPROCESSED
Definition constants.h:20
#define ACTOR_LIFECYCLE_FORCE_HIDDEN
Definition constants.h:44
#define ACTOR_BEHAVIOR_COLLISION_CORRECTION
Definition constants.h:33
#define ACTOR_COMPONENT_DISABLE_POSITIVE_COLLISION
Definition constants.h:93
void Actor_ResetChainState(struct Actor_State *actor, int32_t chain_index)
Definition animation.c:748
void Actor_CopyEntityDefaultsToRecord(struct Actor_State *actor)
Definition lifecycle.c:250
bool Actor_CheckAnimationTrigger(struct Actor_State *actor, struct Actor_State *other_actor)
Definition animation.c:693
void Actor_UpdateAttachmentTransform(struct Actor_State *actor)
Definition attachments.c:86
int32_t Actor_ProcessPuppyInteraction(struct Actor_State *actor, struct Actor_State *puppy_actor, struct Collision_Polygon *collision_poly, int32_t collision_depth)
#define g_actorPhaseCallback0
Definition globals.h:33
#define Actor_CheckCollisionConditions_ConditionSubtypeIndexTable
Definition globals.h:15
struct Actor * global_type_Actor_CollisionListHead
Definition globals.h:57
#define Actor_CollisionListHead
Definition globals.h:58
#define Actor_DefaultUpdateCallbackSlot
Definition globals.h:30
void Model_AdvanceAnimation(struct Actor_State *actor)
Definition model.c:21
#define AUDIO_COLLISION_IMPACT_SHIFT
Definition constants.h:55
uint8_t Audio_RegisterCollisionSoundEvent(struct Actor_State *actor, struct Actor_State *other_actor, int32_t sound_key, uint32_t packed_impact_cooldown)
Definition spatial.c:135
#define CAMERA_DEFINITION_MODE_MASK
Definition constants.h:17
#define COLLISION_NODE_TRANSFORM_SECONDARY
Definition constants.h:59
#define COLLISION_SURFACE_TRAIL_MASK
Definition constants.h:97
@ COLLISION_SURFACE_TRAIL_IMPACT
Definition constants.h:102
#define COLLISION_GROUND_NORMAL_MIN_Q12
Definition constants.h:50
@ COLLISION_ACTOR_CLASS_POWERUP
Definition constants.h:70
@ COLLISION_ACTOR_CLASS_PROJECTILE
Definition constants.h:69
@ COLLISION_ACTOR_CLASS_CHARACTER
Definition constants.h:68
#define COLLISION_CALLBACK_DAMAGE_PROBE
Definition constants.h:46
#define COLLISION_CALLBACK_CONTACT_PROBE
Definition constants.h:45
#define COLLISION_SURFACE_TRAIL_SHIFT
Definition constants.h:96
#define COLLISION_POLYGON_PLATFORM_CONTACT_ENABLED
Definition constants.h:27
#define COLLISION_NODE_TRANSFORM_PRIMARY
Definition constants.h:58
@ COLLISION_NODE_MESH
Definition constants.h:7
@ COLLISION_NODE_ORIENTED_BOX
Definition constants.h:8
#define COLLISION_POLYGON_WALL_RESPONSE
Definition constants.h:34
struct Actor_State * Collision_GetValidCollisionTarget(struct Actor_State *actor, int32_t collision_slot)
Definition actors.c:868
void Collision_UpdateActorGroundBarycentric(struct Actor_State *actor)
Definition ground.c:107
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)
Definition ground.c:233
struct Collision_Node * Collision_FindActorGroundContact(struct Actor_State *actor, struct Collision_Polygon **out_polygon)
Definition ground.c:614
void Collision_ResolveActorGroundContact(struct Actor_State *actor)
Definition ground.c:621
#define COMPONENT_COLLISION_CLASS2_UNFLAGGED_ACTOR
Definition enums.h:12
#define COMPONENT_COLLISION_CLASS3_FLAGGED_OWNER
Definition enums.h:15
uint8_t Component_CollisionTargetMask
Definition enums.h:6
#define COMPONENT_COLLISION_CLASS3_OTHER_OWNER
Definition enums.h:18
#define COMPONENT_COLLISION_POWERUP
Definition enums.h:21
#define COMPONENT_COLLISION_CLASS2_FLAGGED_ACTOR
Definition enums.h:9
int32_t Component_GetSpawnFrame(struct Actor_State *actor)
Definition lifecycle.c:47
uint16_t Component_GetDamageAmount(struct Component_ProjectileActorView *comp, int32_t *out_hit_flag)
Definition properties.c:16
void Component_UpdateCollisionDetection(struct Component_CollisionRecord *collision_records, int32_t slot_count, struct Actor_State *actor, struct Actor_State *other_actor, struct Math_Vec3I32 *test_pos)
uint32_t Component_GetSpeedRange(struct Actor_State *actor)
Definition properties.c:70
int32_t Component_CheckActorCollisionTypeAdapter(struct Component_ProjectileActorView *comp, struct Actor_State *other_actor)
Definition collision.c:19
#define EntityNavigationWorkList_StagingBufferPtr
Definition globals.h:15
@ GAME_MODE_GAMEPLAY_3D
Definition enums.h:38
#define g_currentGameMode
Definition globals.h:74
#define INPUT_BUTTON_CONFIRM
Definition constants.h:11
#define INPUT_STATE_DISABLED
Definition constants.h:20
#define INPUT_BUTTON_ACTION_1
Definition constants.h:8
#define INPUT_BUTTON_UP
Definition constants.h:6
#define INPUT_BUTTON_LEFT
Definition constants.h:4
#define INPUT_BUTTON_RIGHT
Definition constants.h:5
#define INPUT_BUTTON_ACTION_3
Definition constants.h:10
#define INPUT_BUTTON_DOWN
Definition constants.h:7
#define INPUT_BUTTON_ACTION_2
Definition constants.h:9
#define g_inputStateCurrentP1
Definition globals.h:72
void Math_BuildMatrixRotationY(struct Math_Matrix3x3I16 *out_matrix, struct Math_Matrix3x3I16 const *left_factor, int32_t angle)
Definition matrices.c:76
void Math_BuildRotationFromVectors(struct Math_Vec3I16 *from_vec, struct Math_Vec3I16 *to_vec, struct Math_Matrix3x3I16 *out_matrix)
Definition matrices.c:366
int32_t Math_SqrtFP12(uint32_t value)
void Math_BuildQuaternionFromMatrix(struct Math_Matrix3x3I16 *matrix, struct Math_QuaternionI16 *output_quat)
Definition matrices.c:250
void Math_MulMat3x3Q12(struct Math_Matrix3x3I16 *out_matrix, struct Math_Matrix3x3I16 const *right_factor, struct Math_Matrix3x3I16 const *left_factor)
Definition matrices.c:11
#define NAVIGATION_COMMAND_DEFAULT_SELECTOR
Definition constants.h:11
#define NAVIGATION_COMMAND_UNLIMITED_SPEED
Definition constants.h:12
char Navigation_QueueDamageResponse(struct Actor_State *actor, struct Component_Instance *damage_component)
Definition commands.c:89
void Navigation_AddCommand(uint8_t command_type, int16_t target_selector_a, int16_t target_selector_b, int32_t speed, struct Math_Vec3I32 const *position)
Definition commands.c:42
#define pkg_resource_current_level_data
Definition globals.h:117
#define PHYSICS_Q12_FRACTION_MASK
Definition constants.h:18
#define PHYSICS_ANGLE_MASK
Definition constants.h:8
#define PHYSICS_QUATERNION_DIAGONAL_HALF_Q28
Definition constants.h:32
#define PHYSICS_FIXED_ONE
Definition constants.h:7
#define PHYSICS_Q14_ONE
Definition constants.h:11
#define PHYSICS_QUATERNION_MATRIX_SHIFT
Definition constants.h:31
#define PHYSICS_GROUND_NORMAL_THRESHOLD_Q24
Definition constants.h:34
#define PHYSICS_FIXED_FRACTION_BITS
Definition constants.h:6
bool Physics_CheckGroundSlopeDirection(struct Actor_State *actor, struct Collision_Polygon *collision_poly, struct Math_Vec3I16 *out_normal, struct Math_Vec3I32 *delta_vec)
Definition ground.c:34
void Powerup_HandleCollection(struct Actor_State *powerup_actor, struct Actor_State *collector_actor)
Definition lifecycle.c:397
#define SCENE_NODE_DISABLED
Definition constants.h:24
int16_t collision_fraction_q12
Definition types.h:50
uint8_t collision_class
Definition types.h:435
int16_t anim_seq_timer
Definition types.h:389
uint8_t component_count
Definition types.h:430
struct Math_Vec3I32 velocity
Definition types.h:446
struct Math_Matrix3x3I16 contact_basis
Definition types.h:380
struct Scene_Node ** render_node_list
Definition types.h:440
int16_t chain_timer
Definition types.h:399
int16_t facing_current
Definition types.h:447
uint8_t transition_phase
Definition types.h:434
uint8_t lifecycle_flags
Definition types.h:392
struct Mesh_RuntimeVertex * runtime_vertex_array
Definition types.h:397
uint8_t actor_type
Definition types.h:391
struct Actor_State * child_actor
Definition types.h:478
struct Collision_Polygon * ground_contact_polygon
Definition types.h:452
struct Collision_Node * ground_collision_node
Definition types.h:451
struct Math_Vec2I16 visual_scale
Definition types.h:395
uint8_t behavior_flags_high
Definition types.h:412
uint8_t render_layer
Definition types.h:394
int32_t behavior_flags
Definition types.h:407
int16_t collision_radius
Definition types.h:423
uint8_t attach_slot_index
Definition types.h:393
int16_t scale_factor
Definition types.h:439
struct Actor_State * parent_actor
Definition types.h:488
int16_t facing_target
Definition types.h:448
struct Math_Vec3I32 world_render_pos
Definition types.h:420
int16_t collision_height
Definition types.h:421
int16_t collision_height_hi
Definition types.h:422
void * record_ptr
Definition types.h:477
struct Math_Vec3I32 sub_pos
Definition types.h:386
int16_t facing_blend
Definition types.h:449
struct Math_Matrix3x3I16 rot_mat
Definition types.h:383
struct Math_Vec3I32 position
Definition types.h:385
struct Actor_State * list_next
Definition types.h:377
int16_t chain_state
Definition types.h:400
uint32_t flags
Definition types.h:297
uint8_t node_type
Definition types.h:286
struct Math_Matrix3x3I16 transform_matrix
Definition types.h:281
uint16_t flags
Definition types.h:66
struct Pkg_CollisionFacePlane * face_plane
Definition types.h:62
Component_CollisionTargetMask collision_positive_mask
Definition types.h:110
uint8_t flags_high
Definition types.h:79
Component_CollisionTargetMask collision_neutral_mask
Definition types.h:109
struct Component_Definition * definition
Definition types.h:322
struct Nav_Command nav_commands[0x64]
Definition types.h:135
struct Pkg_CameraDef * cam_default
Definition types.h:41
int16_t current_entity_index
Definition types.h:43
int16_t m21
Definition types.h:169
int16_t m00
Definition types.h:162
int16_t m01
Definition types.h:163
int16_t m12
Definition types.h:167
int16_t m11
Definition types.h:166
int16_t m20
Definition types.h:168
int16_t m22
Definition types.h:170
int16_t m02
Definition types.h:164
int16_t m10
Definition types.h:165
int16_t x
Definition types.h:402
int16_t y
Definition types.h:403
int16_t z
Definition types.h:460
int16_t x
Definition types.h:458
int16_t y
Definition types.h:459
int32_t y
Definition types.h:471
int32_t x
Definition types.h:470
int32_t z
Definition types.h:472
int16_t target_selector_b
Definition types.h:73
uint32_t command_type
Definition types.h:71
struct Math_Vec3I16 normal
Definition types.h:1135
struct Player_HazardContactView hazard_contacts[0x4]
Definition types.h:196
struct Math_Vec3I16 contact_normal_q12
Definition types.h:132
struct Actor_State * nearest_class4_actor
Definition types.h:191
uint32_t collision_response_slot_bits[7]
Definition types.h:188
int16_t pending_contact_priority_q12
Definition types.h:135
uint16_t reaction_animation_ticks
Definition types.h:136
struct Component_CollisionRecord * component_records
Definition types.h:209
struct Actor_State * pending_ground_actor
Definition types.h:184
struct Math_Vec3I32 relative_contact_velocity_q12
Definition types.h:134
struct Scene_Node * camera_override_node
Definition types.h:185
struct Math_Vec3I32 queued_impulse_q12
Definition types.h:177
struct Actor_State * actor
Definition types.h:97
struct Math_Vec3I32 impulse_direction
Definition types.h:99
#define g_frameCounter
Definition values.h:501