102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference | GitLab repository
Loading...
Searching...
No Matches
effects.c
Go to the documentation of this file.
1/* Recovered game implementation; original addresses identify provenance. */
13#include "pcdogs/game/globals.h"
14#include "pcdogs/game/types.h"
24#include "pcdogs/level/types.h"
27#include "pcdogs/math/globals.h"
28#include "pcdogs/math/types.h"
37#include "pcdogs/trail/types.h"
38#include <math.h>
39#include <stdarg.h>
40#include <string.h>
41
42// Original pcdogs.exe: 0x4017b0
43// Performs fallback decay for unprocessed actor trails and renders surviving trails unless frame flag 0x2000 suppresses rendering. It clears every trail's processed flag after the sweep.
45{
46 struct Actor *actor_trail_view = (struct Actor *)(actor);
47 int32_t trail_count = actor_trail_view->trail_count;
48 int32_t trails_remaining = trail_count;
49
50 if (!trails_remaining)
51 return;
52
53 struct Component_TrailObject *trail_chain_ptr = actor_trail_view->trail_chain_ptr;
54 int32_t remaining_before_decrement;
55
56 do
57 {
58 if (trail_chain_ptr->expiry_countdown && !trail_chain_ptr->processed_flag && Trail_UpdateEffect(trail_chain_ptr, NULL, NULL, 0) && !(((uint32_t)Game_FrameTransitionFlags >> 8) & (GAME_TRANSITION_FADE_COUNTDOWN >> 8)))
59 {
60 Trail_RenderAnimated((struct Trail_RenderRuntimeView *)trail_chain_ptr, NULL, NULL);
61 }
62
63 trail_chain_ptr->processed_flag = 0;
64 trail_chain_ptr = &trail_chain_ptr[1];
65 remaining_before_decrement = trails_remaining;
66 trails_remaining -= 1;
67 } while (remaining_before_decrement != 1);
68}
69
70// Original pcdogs.exe: 0x401810
71// Samples or decays a trail segment and marks the trail processed. Each call advances the ring unless expiry reaches zero, which resets its head and returns zero; flag 0x02 skips sampling and expiry work while retaining advancement.
73 const struct Actor_State *actor,
74 const struct Graphics_Render_PolygonRenderRef *polygon_ref, char active)
75{
76 trail->processed_flag = 1;
77 trail->segment_index = trail->head_index;
78
79 if (trail->segment_index < 0)
80 trail->segment_index += trail->max_segments;
81
82 if (!(trail->flags & TRAIL_SKIP_SAMPLE_AND_EXPIRY))
83 {
84 struct Trail_Segment *segment = &trail->segment_array[trail->segment_index];
85
86 segment->active = (int32_t)active;
87
88 if (segment->active)
89 {
90 trail->expiry_countdown = trail->max_segments;
91 memcpy(&segment->world_transform, g_renderWorldTransformPtr, 0x20);
92 /* Native copies include the word after each XYZ endpoint. */
93 memcpy(&segment->start, &actor->runtime_vertex_array[polygon_ref->vertex_indices[0]], 8);
94 memcpy(&segment->end, &actor->runtime_vertex_array[polygon_ref->vertex_indices[3]], 8);
95
96 if (actor->actor_type == ACTOR_OBJECT_RUNTIME)
97 {
98 segment->start.x >>= 4;
99 segment->start.y >>= 4;
100 segment->start.z >>= 4;
101 segment->end.x >>= 4;
102 segment->end.y >>= 4;
103 segment->end.z >>= 4;
104 }
105 }
106 else if (--trail->expiry_countdown == 0)
107 {
108 trail->head_index = -(int16_t)trail->max_segments;
109
110 return 0;
111 }
112 }
113
114 ++trail->head_index;
115
116 if (trail->head_index == trail->max_segments)
117 trail->head_index = 0;
118
119 return 1;
120}
121
122// Original pcdogs.exe: 0x409450
123// Spawns a configured trail entry through a collision-record component or an actor-template clone. Entries 1 through 4 receive the additional Y offset on either spawn path.
124struct Actor_State *Trail_SpawnFromEntry(struct Actor_State *actor, int32_t trail_index)
125{
127 struct Trail_Entry *trail_list = level->trail_list;
128 // Powerup table entry: 8 bytes per entry. Offset +4 = Actor template pointer
129 struct Actor_State *template_actor = trail_list[trail_index].data_ptr;
130
131 if (!template_actor)
132 return NULL;
133
134 struct Actor_State *result;
135 struct Actor_State *target_actor;
136
137 // Check trail entry kind: 0=ObjectNode, nonzero(always 1)=ComponentData
138 if (trail_list[trail_index].data_type)
139 {
140 target_actor = actor;
141
142 struct Component_CollisionRecord collision_spawn_record;
143
144 collision_spawn_record.definition = 0;
145 memset(&collision_spawn_record.attachment_joint_index, 0, sizeof(collision_spawn_record) - sizeof(collision_spawn_record.definition));
146
147 struct Component_CollisionRecord *collision_record = &collision_spawn_record;
148 struct Component_Definition *component_definition = level->trail_list[trail_index].data_ptr;
149 struct Actor_State *owner_actor = target_actor;
150
151 collision_spawn_record.definition = component_definition;
152 result = Component_SpawnFromCollisionRecord(owner_actor, target_actor, collision_record);
153 }
154 else
155 {
156 // Mode 0: Direct clone - allocates 384 bytes, shares mesh geometry with template
157 result = Actor_CloneTemplateWithTemplateRelativeFixups(template_actor, (struct Actor_State **)(uintptr_t)(&Projectile_LiveActorListHead));
158
159 if (!result)
160 return NULL;
161
162 target_actor = actor;
163
165
166 result->movement_handler_index = 0;
167 // Set spawn flags: 0x400000=SPAWNED, 0x800=POWERUP_SOURCE, 0x200=ATTACHED_PLATFORM
168 result->behavior_flags = spawn_behavior_flags;
169 result->transition_phase = 0;
170 result->collision_class = 0;
171 result->ground_collision_node = target_actor->ground_collision_node;
172 result->ground_contact_polygon = target_actor->ground_contact_polygon;
173 }
174
175 if (!result)
176 return NULL;
177
178 struct Actor_State *child_actor = target_actor->child_actor;
179 struct Math_Matrix3x3I16 *source_transform;
180
181 if (child_actor)
182 source_transform = &child_actor->rot_mat;
183 else
184 source_transform = &target_actor->rot_mat;
185
186 memcpy(&result->rot_mat, source_transform, 0x20);
187
188 if (trail_index != 3 && trail_index != 1 && trail_index != 2 && trail_index != 4)
189 return result;
190
191 result->position.y += 0x1000;
192
193 return result;
194}
195
201
207
208static int32_t trail_translation(const int16_t *row, const struct Math_Vec3I32 *position)
209{
210 return (int32_t)(((int64_t)row[0] * position->x + (int64_t)row[1] * position->y + (int64_t)row[2] * position->z) >> 12);
211}
212
213static int32_t trail_view_coordinate(const int16_t *row, const struct Math_Vec3I16 *point, int32_t origin)
214{
215 uint32_t dot = (uint32_t)(row[0] * point->x) + (uint32_t)(row[1] * point->y) + (uint32_t)(row[2] * point->z);
216 return origin + ((int32_t)dot >> 6);
217}
218
219static int32_t trail_screen_coordinate(int32_t view, int32_t scale, int32_t extent)
220{
221 return ((int32_t)(((int64_t)scale * view) >> 12) >> 12) + (extent >> 1);
222}
223
224static void project_trail_point(const struct Math_Vec3I16 *point, struct TrailProjectedPoint *out)
225{
226 const int16_t *matrix = g_cameraTransformMatrix.elements;
227 int32_t x = trail_view_coordinate(matrix, point, g_nodeViewTranslationX);
228 int32_t y = trail_view_coordinate(matrix + 3, point, g_nodeViewTranslationY);
229 int32_t z = trail_view_coordinate(matrix + 6, point, g_nodeViewTranslationZ);
230 out->view = (struct Math_Vec3F){x / 64.0f, y / 64.0f, z / 64.0f};
231 out->screen.z = z;
232 if (z <= render_list_state->projection_near_fp)
233 return;
234
235 int32_t scale = (int64_t)render_list_state->focal_distance * 4096 / z;
236 int32_t sx = trail_screen_coordinate(x, scale, Graphics_WindowWidth);
237 int32_t sy = trail_screen_coordinate(y, scale, Graphics_WindowHeight);
238 if (sx != (int16_t)sx || sy != (int16_t)sy)
239 out->screen.z = render_list_state->projection_near_fp;
240 else
241 {
242 out->screen.screen.x = (int16_t)sx;
243 out->screen.screen.y = (int16_t)sy;
244 }
245}
246
247static int16_t trail_width_coordinate(int16_t start, int16_t end, int32_t fraction)
248{
249 return (int16_t)(start + (((int64_t)(int16_t)(end - start) * fraction) >> 12));
250}
251
252static void project_trail_edge(const struct Trail_Segment *segment, int32_t width, struct TrailProjectedEdge *edge)
253{
254 const struct Math_Vec3I32 *translation = &segment->world_transform.translationQ6;
255 const struct Graphics_Render_ListState *view = render_list_state;
256 const int16_t *matrix = view->node_view_matrix.elements;
258 g_nodeViewTranslationY = view->node_view_translation.y + trail_translation(matrix + 3, translation);
259 g_nodeViewTranslationZ = view->node_view_translation.z + trail_translation(matrix + 6, translation);
261
262 const struct Math_Vec3I16 *start = &segment->start, *end = &segment->end;
263 struct Math_Vec3I16 across = {trail_width_coordinate(start->x, end->x, width),
264 trail_width_coordinate(start->y, end->y, width),
265 trail_width_coordinate(start->z, end->z, width)};
266 project_trail_point(start, &edge->start);
267 project_trail_point(&across, &edge->width);
268}
269
270static int32_t trail_depth_bucket(const struct TrailProjectedEdge *previous, const struct TrailProjectedEdge *current)
271{
272 /* The x87 code compares a 0/1 equality result with the current width depth. */
273 int32_t equal_starts = previous->start.view.z == current->start.view.z;
274 long double depth;
275 if ((float)equal_starts == current->width.view.z)
276 depth = (long double)previous->start.view.z * g_levelRenderDistance;
277 else
278 depth = ((long double)current->width.view.z + current->start.view.z + previous->start.view.z + previous->width.view.z) * g_levelRenderDistanceQuarter;
279
280 int32_t index = __ftol_msvc(depth);
281 if (index >= TRAIL_SORT_BUCKET_MAX)
282 return 1;
283 int32_t bucket = (int32_t)((uint32_t)TRAIL_SORT_BUCKET_MAX - (uint32_t)index);
284 return bucket < 1 ? 1 : bucket > TRAIL_SORT_BUCKET_MAX ? TRAIL_SORT_BUCKET_MAX
285 : bucket;
286}
287
288static uint32_t trail_gray(int32_t intensity_q12)
289{
290 uint32_t intensity = (uint32_t)(intensity_q12 >> 12);
291 uint32_t channel = (uint8_t)intensity;
292 return (channel << 16) | (channel << 8) | intensity;
293}
294
295static uint32_t trail_fade(uint32_t rgb, int32_t scale)
296{
297 uint32_t red = ((rgb & 0xff) * scale) >> 8;
298 uint32_t green = ((rgb >> 8 & 0xff) * scale) & 0xff000;
299 uint32_t blue = (((rgb >> 12 & 0xff0) * scale) & 0xff0000);
300 return ((red | green) >> 4) | blue;
301}
302
303// Original pcdogs.exe: 0x422790
304void Trail_RenderAnimated(struct Trail_RenderRuntimeView *trail, struct Actor_State *actor, struct Submesh_RenderSpan *span)
305{
306 (void)actor;
307 (void)span;
308 int32_t index = trail->head_index;
309 int32_t skipped = 0;
310 if (index < 0)
311 {
312 skipped = 1 - index;
313 index = 0;
314 }
315
316 while (index != trail->segment_index && !trail->segment_array[index].active)
317 {
318 ++skipped;
319 if (++index == trail->max_segments)
320 index = 0;
321 }
322 if (index == trail->segment_index)
323 return;
324
325 int32_t width = trail->width_step_q12 * skipped;
326 int32_t intensity = trail->intensity_step_q12 * skipped;
327 int32_t frames_left = trail->max_segments - 1 - skipped;
328 /* Failed projections retain prior XY. The first such slot has no defined native XY. */
329 struct TrailProjectedEdge previous = {0}, current = {0};
330 project_trail_edge(&trail->segment_array[index], width, &previous);
331
332 do
333 {
335 batch->vertex_colors[0] = batch->vertex_colors[3] = trail_gray(intensity);
336 width += trail->width_step_q12;
337 intensity += trail->intensity_step_q12;
338 --frames_left;
339 if (++index == trail->max_segments)
340 index = 0;
341 if (!trail->segment_array[index].active)
342 continue;
343
344 project_trail_edge(&trail->segment_array[index], width, &current);
345 int32_t bucket = trail_depth_bucket(&previous, &current);
346 const struct TrailProjectedPoint *corners[] = {&previous.start, &current.start, &current.width, &previous.width};
347 batch->face_normal_dot = 0;
348 for (int i = 0; i < 4; ++i)
349 batch->view_vertices[i] = corners[i]->view;
350 batch->vertex_colors[1] = batch->vertex_colors[2] = trail_gray(intensity);
351
352 struct MaterialControllerGroup *controllers = trail->controller_group;
353 if (controllers)
354 {
355 struct MaterialControllerSlot **slot = controllers->controller_slot_array;
356 int remaining = controllers->controller_count;
357 do
358 {
359 Animation_ProcessController(trail->material_nodes, &(*slot++)->packed_state, frames_left);
360 } while (--remaining);
361 }
363 Graphics_SetPolygonUVs(NULL, batch, trail->material, -1, NULL);
364
366 struct Graphics_Render_PolygonBatchRecord **head = &render_list_state->sorted_list_head;
368 head = &render_list_state->polygon_queue_heads[bucket];
370 head = &render_list_state->sorted_list_buckets[TRAIL_LAST_SORTED_BUCKET];
371 batch->next_in_bucket = *head;
372 *head = batch;
373 for (int i = 0; i < 4; ++i)
374 {
375 batch->screen_vertices[i] = corners[i]->screen;
376 batch->view_vertices[i] = corners[i]->view;
378 batch->vertex_colors[i] = trail_fade(batch->vertex_colors[i], 4096 - g_renderingStateFlag);
379 }
380
381 previous = current;
383 } while (index != trail->segment_index);
384}
385
386// Original pcdogs.exe: 0x438810
387// Returns -1 when the level has no navigation network; otherwise it returns whether the bone-trail timer is nonnegative.
389{
391 return 0xffffffff;
392
393 int32_t result = g_boneTrailTimer >= 0;
394
395 return result;
396}
397
398// Original pcdogs.exe: 0x438840
399// Resets the bone-trail timer and path counters and clears the spawn timestamps of five queue entries. Other entry fields are retained.
410
411// Original pcdogs.exe: 0x438870
412// Updates bone guidance timing, path selection and queued actor spawning, then refills eligible queue entries. Path-prefix compaction preserves queue-index adjustments, and timestamp comparisons remain unsigned.
413void Trail_UpdateAndRenderBone(struct Actor_State *actor, struct Math_Vec3I32 *movement_vec)
414{
415 int32_t segment_scale_q12;
416
418 return;
419
420 struct Actor_State *active_actor = actor;
421 bool trail_timer_active = g_boneTrailTimer >= 0;
422
424
425 if (!trail_timer_active)
426 {
428 {
430 {
432
433 return;
434 }
435
437 }
438 else
439 {
440 int32_t previous_warmup_timer = g_boneTrailTimer;
441
442 g_boneTrailTimer = previous_warmup_timer + 1;
443
444 if (previous_warmup_timer != -1)
445 {
446 int32_t advanced_warmup_timer = g_boneTrailTimer;
447
449
450 if (advanced_warmup_timer == -TRAIL_BONE_PATH_SEARCH_TICKS)
451 {
452 int32_t skip_dynamic_targets = ((struct Player_ControllerRecordView *)active_actor->record_ptr)->health_or_energy >= PLAYER_MAX_HEALTH;
453 int32_t found_path_node_count = Trail_FindBonePath(&active_actor->position,
454 pkg_resource_current_level_data->nav_net, skip_dynamic_targets);
455
456 g_boneTrailPathNodeCount = found_path_node_count;
457
458 if (found_path_node_count)
459 {
460 movement_vec->x = g_boneTrailTargetPosition - active_actor->position.x;
461 movement_vec->y = g_boneTrailAnimTime - active_actor->position.y;
462 movement_vec->z = g_boneTrailPathBuffer_Z1 - active_actor->position.z;
463
464 return;
465 }
466
468
469 return;
470 }
471
473 {
474 movement_vec->x = g_boneTrailTargetPosition - active_actor->position.x;
475 movement_vec->y = g_boneTrailAnimTime - active_actor->position.y;
476 movement_vec->z = g_boneTrailPathBuffer_Z1 - active_actor->position.z;
477 }
478
479 return;
480 }
481
484 }
485 }
486
487 int32_t path_node_count = g_boneTrailPathNodeCount;
488
489 if (!path_node_count)
490 return;
491
492 int32_t goal_entity_or_powerup_index = Trail_ResetBone_CurrentPathNodeSelector - NAVIGATION_ENTITY_GOAL_FIRST;
493 struct Powerup_Entry *goal_powerup;
494
495 if (goal_entity_or_powerup_index < NAVIGATION_ENTITY_GOAL_COUNT)
496 {
497 goal_powerup = NULL;
498
500 {
502
503 return;
504 }
505 }
506 else
507 {
508 struct Powerup_Entry *resolved_powerup = &pkg_resource_current_level_data->powerup_list[goal_entity_or_powerup_index - NAVIGATION_ENTITY_GOAL_COUNT];
509
510 goal_powerup = resolved_powerup;
511
512 if (resolved_powerup->flags & (POWERUP_ENTRY_COLLECTED | POWERUP_ENTRY_DISABLED))
513 {
515
516 return;
517 }
518
519 char powerup_type = resolved_powerup->powerup_type;
520
522 {
524
525 return;
526 }
527 }
528
529 struct Math_Vec3I32 *retained_path_start = NULL;
530 struct Math_Vec3I32 *path_cursor = &Trail_BonePathNodes[1];
531 int32_t segments_remaining = path_node_count - 1;
532 struct Math_Vec3I32 *saved_path_cursor = &Trail_BonePathNodes[1];
533 struct Math_Vec3I32 path_relative_vector;
534 struct Math_Vec3I32 segment_step_vector;
535
536 while (true)
537 {
538 int32_t segment_end_z = path_cursor->z;
539 struct Math_Vec3I32 *segment_start = &path_cursor[-1];
540
541 segment_step_vector.x = path_cursor[-1].z - segment_end_z;
542
543 int32_t segment_end_x = (uint32_t)path_cursor->x;
544
545 segment_step_vector.z = segment_end_x - (uint32_t)segment_start->x;
546
547 int32_t actor_y = active_actor->position.y;
548
549 path_relative_vector.x = segment_end_x - active_actor->position.x;
550 path_relative_vector.y = path_cursor->y - actor_y;
551 path_relative_vector.z = segment_end_z - active_actor->position.z;
552
553 int32_t end_side_test = ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * path_relative_vector.x)) >> 12)) - ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * path_relative_vector.z)) >> 12));
554
555 if (end_side_test > 0)
556 {
557 int32_t segment_start_y = path_cursor[-1].y;
558
559 path_relative_vector.x = (uint32_t)segment_start->x - active_actor->position.x;
560
561 int32_t segment_start_z = path_cursor[-1].z;
562
563 path_relative_vector.y = segment_start_y - active_actor->position.y;
564 path_relative_vector.z = segment_start_z - active_actor->position.z;
565
566 int32_t start_side_x_term = (int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * path_relative_vector.x)) >> 12);
567 int32_t start_side_z_term = (int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * path_relative_vector.z)) >> 12);
568 int32_t start_side_test = start_side_x_term - start_side_z_term;
569
570 if (start_side_x_term - start_side_z_term < 0)
571 {
572 int32_t segment_end_y = path_cursor->y;
573
574 segment_step_vector.x = (uint32_t)path_cursor->x - (uint32_t)segment_start->x;
575
576 int32_t segment_end_z_snapshot = path_cursor->z;
577
578 segment_step_vector.y = segment_end_y - path_cursor[-1].y;
579 segment_step_vector.z = segment_end_z_snapshot - path_cursor[-1].z;
580 segment_scale_q12 = ((int64_t)start_side_test * 4096) / (start_side_test - end_side_test);
581
582 segment_step_vector.x = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.x)) >> 12);
583 segment_step_vector.y = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.y)) >> 12);
584
585 int32_t interpolation_start_z = path_cursor[-1].z;
586 int32_t interpolated_point_x = segment_step_vector.x + (uint32_t)segment_start->x;
587 int32_t interpolated_point_y = segment_step_vector.y + path_cursor[-1].y;
588
589 segment_step_vector.x = interpolated_point_x;
590
591 int32_t interpolated_point_z = ((int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.z)) >> 12)) + interpolation_start_z;
592 int32_t actor_x = actor->position.x;
593
594 segment_step_vector.z = interpolated_point_z;
595 segment_step_vector.y = interpolated_point_y;
596 path_relative_vector.x = interpolated_point_x - actor_x;
597 path_relative_vector.z = interpolated_point_z - actor->position.z;
598 }
599
600 path_relative_vector.y = 0;
601
602 if (((int32_t)((uint64_t)(((int64_t)(path_relative_vector.z) * path_relative_vector.z) + ((int64_t)(path_relative_vector.x) * path_relative_vector.x) + ((int64_t)(path_relative_vector.y) * path_relative_vector.y)) >> 12)) >= 0x5000)
603 active_actor = actor;
604 else
605 {
606 if (start_side_test < 0)
607 {
608 int32_t retained_point_y = segment_step_vector.y;
609
610 segment_start->x = segment_step_vector.x;
611
612 int32_t retained_point_z = segment_step_vector.z;
613
614 segment_start->y = retained_point_y;
615 segment_start->z = retained_point_z;
616 }
617
618 path_cursor = saved_path_cursor;
619 active_actor = actor;
620 retained_path_start = segment_start;
621
622 path_cursor = &path_cursor[1];
623
624 bool more_path_segments = segments_remaining != 1;
625
626 saved_path_cursor = path_cursor;
627 segments_remaining -= 1;
628
629 if (more_path_segments)
630 continue;
631 }
632
633 if (!retained_path_start)
634 {
635 // Original JNZ at 0x438be6 leaves this staleness check live when
636 // no path cursor was selected. Timestamp comparison is unsigned.
637 int32_t oldest_entry_timestamp = Trail_BoneQueue[0].spawn_frame;
638
639 if (!oldest_entry_timestamp || (uint32_t)oldest_entry_timestamp + TRAIL_MARKER_LIFETIME_FRAMES < (uint32_t)g_frameCounter)
641
642 break;
643 }
644 }
645 else if (!retained_path_start)
646 {
647 // Original JNZ at 0x438a7e leaves this cursor-selection block reachable.
648 if (segments_remaining > 1)
649 retained_path_start = path_cursor;
650
651 path_cursor = &path_cursor[1];
652
653 bool more_path_segments = segments_remaining != 1;
654
655 saved_path_cursor = path_cursor;
656 segments_remaining -= 1;
657
658 if (more_path_segments)
659 continue;
660
661 if (!retained_path_start)
662 {
663 int32_t oldest_entry_timestamp = Trail_BoneQueue[0].spawn_frame;
664
665 if (!oldest_entry_timestamp || (uint32_t)oldest_entry_timestamp + TRAIL_MARKER_LIFETIME_FRAMES < (uint32_t)g_frameCounter)
667
668 break;
669 }
670 }
671
672 int32_t removed_point_bytes = (char *)retained_path_start - (char *)&g_boneTrailPathNodes;
673 int32_t removed_path_points = removed_point_bytes / 12;
674
675 if ((uint32_t)removed_point_bytes < 12u)
676 break;
677
678 // Original JZ at 0x438c1e leaves path-prefix compaction reachable.
679 int32_t remaining_path_points = g_boneTrailPathNodeCount - removed_path_points;
680
681 g_boneTrailPathNodeCount = remaining_path_points;
682
683 int32_t remaining_path_bytes = remaining_path_points * 0xc;
684
685 memmove(&g_boneTrailPathNodes, retained_path_start, remaining_path_bytes);
686
687 struct Trail_BoneQueueEntry *entry_cursor = Trail_BoneQueue;
688
689 do
690 {
691 if (entry_cursor->spawn_frame)
692 {
693 int32_t entry_path_index = entry_cursor->segment_index;
694
695 entry_cursor->segment_index = entry_path_index - removed_path_points;
696
697 if (entry_path_index - removed_path_points < 0)
698 entry_cursor->spawn_frame = 0;
699 }
700
701 ++entry_cursor;
702 } while (entry_cursor < Trail_BoneQueue + TRAIL_BONE_QUEUE_CAPACITY);
703
704 break;
705 }
706
708 return;
709
710 int32_t expired_entry_count = 0;
711
712 for (struct Trail_BoneQueueEntry *entry_cursor = Trail_BoneQueue; entry_cursor < Trail_BoneQueue + TRAIL_BONE_QUEUE_CAPACITY;)
713 {
714 if (entry_cursor->spawn_frame)
715 {
716 if (!entry_cursor->segment_index)
717 {
718 int32_t first_path_start_z = g_boneTrailPathBuffer_Z;
719 int32_t first_path_end_x = g_boneTrailTargetPosition;
720
721 segment_step_vector.x = first_path_start_z - g_boneTrailPathBuffer_Z1;
722
723 int32_t first_path_start_x = g_boneTrailPathNodes;
724
725 segment_step_vector.z = first_path_end_x - first_path_start_x;
726
727 int32_t entry_position_y = entry_cursor->position.y;
728
729 path_relative_vector.x = first_path_start_x - (uint32_t)entry_cursor->position.x;
730
731 int32_t entry_to_start_z = first_path_start_z - entry_cursor->position.z;
732
733 path_relative_vector.y = g_boneTrailPathBuffer_Y - entry_position_y;
734 path_relative_vector.z = entry_to_start_z;
735 }
736
737 if (entry_cursor->segment_index || ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * path_relative_vector.x)) >> 12)) - ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * path_relative_vector.z)) >> 12)) <= 0)
738 {
739 int32_t retained_entry_bytes = (5 - expired_entry_count) << 5;
740
741 memmove(Trail_BoneQueue, &Trail_BoneQueue[expired_entry_count], retained_entry_bytes);
742
743 if (5 - expired_entry_count < 5)
744 {
745 struct Trail_BoneQueueEntry *cleared_entry = &Trail_BoneQueue[5 - expired_entry_count];
746
747 do
748 {
749 cleared_entry->spawn_frame = 0;
750 ++cleared_entry;
751 } while (cleared_entry < Trail_BoneQueue + TRAIL_BONE_QUEUE_CAPACITY);
752 }
753
754 int32_t spawn_timestamp = Trail_BoneQueue[0].spawn_frame;
755 int32_t spawn_entry_index = 0;
756
757 if (spawn_timestamp)
758 {
759 struct Trail_BoneQueueEntry *spawn_cursor = Trail_BoneQueue;
760
761 while ((uint32_t)spawn_timestamp < (uint32_t)g_frameCounter)
762 {
763 spawn_timestamp = spawn_cursor[1].spawn_frame;
764 ++spawn_cursor;
765 spawn_entry_index += 1;
766
767 if (!spawn_timestamp)
768 break;
769 }
770
771 if (spawn_entry_index >= 5)
772 {
773 active_actor = actor;
774
775 break;
776 }
777 }
778
779 struct Trail_BoneQueueEntry *spawn_entry = &Trail_BoneQueue[spawn_entry_index];
780
781 if (spawn_entry->spawn_frame != (uint32_t)g_frameCounter)
782 {
783 active_actor = actor;
784
785 break;
786 }
787
789 (struct Actor_State *)pkg_resource_current_level_data->trail_list[6].data_ptr,
791
792 if (spawned_bone_actor)
793 {
795 spawned_bone_actor->movement_handler_index = 0;
796 spawned_bone_actor->transition_phase = 0;
797 spawned_bone_actor->collision_class = 0;
798 spawned_bone_actor->ground_collision_node = NULL;
799 spawned_bone_actor->position.x = (uint32_t)spawn_entry->position.x;
800 spawned_bone_actor->position.y = (uint32_t)spawn_entry->position.y;
801 spawned_bone_actor->position.z = (uint32_t)spawn_entry->position.z;
802
803 int32_t spawned_base_z = spawned_bone_actor->position.z;
804
805 spawned_bone_actor->position.x += (uint32_t)spawn_entry->lateral_offset_x;
806 spawned_bone_actor->position.z = spawned_base_z + (uint32_t)spawn_entry->lateral_offset_z;
807 spawned_bone_actor->facing_current = (uint16_t)spawn_entry->facing_angle;
808 spawned_bone_actor->facing_blend = 0x1000;
809 }
810
811 active_actor = actor;
812
813 break;
814 }
815
816 entry_cursor->spawn_frame = 0;
817 }
818
819 ++entry_cursor;
820 expired_entry_count += 1;
821 }
822
823 int32_t input_player_index = ((struct Player_ControllerRecordView *)active_actor->record_ptr)->input_source_index;
824 bool keep_trail_active;
825
826 if (!(g_inputStateCurrentP1[input_player_index].button_bits & INPUT_BUTTON_ACTION_3))
827 {
828 int32_t previous_active_timer = g_boneTrailTimer;
829
830 g_boneTrailTimer -= 1;
831 keep_trail_active = previous_active_timer != 1;
832
833 if (!keep_trail_active)
835
836 return;
837 }
838
839 if (g_boneTrailPathCount != 2)
841
843
844 if (!retained_path_start)
845 {
846 // Original JNZ at 0x438e75 selects refill only for a non-null path cursor.
847 keep_trail_active = Trail_BoneQueue[0].spawn_frame;
848
849 if (!keep_trail_active)
851
852 return;
853 }
854
855 struct Math_Vec3I32 *previous_marker_position = Trail_BonePathNodes;
856 int32_t remaining_segment_distance = 0;
857 int32_t saved_marker_index = 0;
858 int32_t marker_index = 0;
859 struct Math_Vec3I32 *path_node = &Trail_BonePathNodes[1];
860 struct Math_Vec3I32 *previous_marker_position_saved = Trail_BonePathNodes;
861 struct Math_Vec3I32 *next_node = &Trail_BonePathNodes[1];
862 int32_t next_spawn_frame = g_frameCounter + 1;
863
864 while (true)
865 {
866 struct Trail_BoneQueueEntry *marker_entry = &Trail_BoneQueue[marker_index];
867 int32_t marker_timestamp = Trail_BoneQueue[marker_index].spawn_frame;
868
869 if (!marker_timestamp)
870 {
871 if (remaining_segment_distance < 0)
872 {
873 int32_t previous_marker_z = previous_marker_position->z;
874
875 segment_step_vector.x = (int32_t)(path_node->x - previous_marker_position->x);
876 segment_step_vector.y = (int32_t)(path_node->y - previous_marker_position->y);
877 segment_step_vector.z = (int32_t)(path_node->z - previous_marker_z);
878 segment_step_vector.y = 0;
879
880 remaining_segment_distance =
881 Math_SqrtFP12((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * segment_step_vector.z) + ((int64_t)(segment_step_vector.x) * segment_step_vector.x) + ((int64_t)(segment_step_vector.y) * segment_step_vector.y)) >> 12));
882 segment_step_vector.x = (int32_t)(next_node->x - next_node[-1].x);
883 segment_step_vector.y = (int32_t)(next_node->y - next_node[-1].y);
884 segment_step_vector.z =
885 (int32_t)((uintptr_t)next_node->z - (uint32_t)next_node[-1].z);
886
887 int32_t resume_segment_length = Math_SqrtFP12(((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * segment_step_vector.z)) >> 12)) + ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * segment_step_vector.x)) >> 12)));
888
889 if (resume_segment_length)
890 {
891 segment_scale_q12 = INT64_C(33554432) / resume_segment_length;
892
893 segment_step_vector.x = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.x)) >> 12);
894 segment_step_vector.y = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.y)) >> 12);
895 segment_step_vector.z = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.z)) >> 12);
896 }
897
898 previous_marker_position = previous_marker_position_saved;
899 next_node = (struct Math_Vec3I32 *)(&next_node[1]);
900 path_node = next_node;
901 }
902
903 if (remaining_segment_distance < 0x2000)
904 {
905 while (true)
906 {
908 {
909 if (!goal_powerup || !(goal_powerup->flags & POWERUP_ENTRY_TRAIL_TARGET_PENDING))
910 return;
911
912 segment_step_vector.x =
913 path_node[-1].x - (uint32_t)goal_powerup->pos.x;
914 segment_step_vector.y =
915 path_node[-1].y - (uint32_t)goal_powerup->pos.y;
916 segment_step_vector.z = (uint32_t)path_node[-1].z - (uint32_t)goal_powerup->pos.z;
917 next_node = (struct Math_Vec3I32 *)(&segment_step_vector);
918
919 if (((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * segment_step_vector.z) + ((int64_t)(segment_step_vector.x) * segment_step_vector.x) + ((int64_t)(segment_step_vector.y) * segment_step_vector.y)) >> 12)) >= 0x400)
920 return;
921
923 goal_powerup->flags &= (uint8_t)~POWERUP_ENTRY_TRAIL_TARGET_PENDING;
924
925 return;
926 }
927
928 if (saved_marker_index)
929 {
930 segment_step_vector.x = path_node[-1].x - (uintptr_t)path_node->x;
931 segment_step_vector.y = path_node[-1].y - (uintptr_t)path_node->y;
932 segment_step_vector.z =
933 (uint32_t)path_node[-1].z - (uintptr_t)path_node->z;
934
935 int32_t backward_segment_length = Math_SqrtFP12(((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * segment_step_vector.z)) >> 12)) + ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * segment_step_vector.x)) >> 12)));
936
937 if (backward_segment_length)
938 {
939 segment_scale_q12 = ((int64_t)remaining_segment_distance * 4096) / backward_segment_length;
940
941 segment_step_vector.x = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.x)) >> 12);
942 segment_step_vector.y = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.y)) >> 12);
943
944 int32_t backward_offset_z = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.z)) >> 12);
945 int32_t backward_offset_x = segment_step_vector.x;
946 int32_t backward_offset_y = segment_step_vector.y;
947
948 segment_step_vector.z = backward_offset_z;
949 path_relative_vector.x = path_node[-1].x + backward_offset_x;
950 path_relative_vector.y = path_node[-1].y + backward_offset_y;
951 path_relative_vector.z = (uint32_t)path_node[-1].z + backward_offset_z;
952
953 previous_marker_position = &path_relative_vector;
954 }
955 }
956
957 int32_t marker_origin_y = previous_marker_position->y;
958
959 segment_step_vector.x = (int32_t)(path_node->x - previous_marker_position->x);
960
961 int32_t marker_origin_z = previous_marker_position->z;
962
963 segment_step_vector.y = (int32_t)(path_node->y - marker_origin_y);
964 segment_step_vector.z = (int32_t)(path_node->z - marker_origin_z);
965
966 int32_t next_segment_length =
967 Math_SqrtFP12(((int32_t)((uint64_t)(((int64_t)(segment_step_vector.z) * segment_step_vector.z)) >> 12)) + ((int32_t)((uint64_t)(((int64_t)(segment_step_vector.x) * segment_step_vector.x)) >> 12)));
968
969 remaining_segment_distance = next_segment_length;
970
971 if (next_segment_length)
972 {
973 segment_scale_q12 = INT64_C(33554432) / remaining_segment_distance;
974
975 segment_step_vector.x = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.x)) >> 12);
976 segment_step_vector.y = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.y)) >> 12);
977 segment_step_vector.z = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.z)) >> 12);
978 }
979
980 path_node = (struct Math_Vec3I32 *)(&path_node[1]);
981 next_node = path_node;
982
983 if (remaining_segment_distance >= 0x2000)
984 break;
985 }
986 }
987
988 remaining_segment_distance -= 0x2000;
989
990 int32_t marker_step_x = segment_step_vector.x;
991
992 marker_entry->segment_index = ((char *)path_node - (char *)&g_boneTrailPathNodes) / 0xc - 2;
993
994 int32_t marker_step_y = segment_step_vector.y;
995
996 marker_entry->position.x = previous_marker_position->x + marker_step_x;
997
998 int32_t marker_step_z = segment_step_vector.z;
999
1000 marker_entry->position.y = previous_marker_position->y + marker_step_y;
1001 marker_entry->position.z = previous_marker_position->z + marker_step_z;
1002
1003 int32_t lateral_random_offset = Math_GenerateRandom(0x1000) - 0x800;
1004
1005 segment_scale_q12 = ((int64_t)lateral_random_offset * 4096) / 0x2000;
1006
1007 marker_entry->lateral_offset_x = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12) * -(segment_step_vector.z))) >> 12);
1008
1009 int32_t lateral_offset_z = (int32_t)((uint64_t)(((int64_t)(segment_scale_q12)*segment_step_vector.x)) >> 12);
1010
1011 marker_entry->lateral_offset_z = lateral_offset_z;
1012
1013 int32_t previous_jittered_x;
1014 int32_t previous_jittered_z;
1015
1016 if (saved_marker_index)
1017 {
1018 previous_jittered_x = (uint32_t)Trail_BoneQueue[marker_index - 1].lateral_offset_x + Trail_BoneQueue[marker_index - 1].position.x;
1019 previous_jittered_z = Trail_BoneQueue[marker_index - 1].position.z + (uint32_t)Trail_BoneQueue[marker_index - 1].lateral_offset_z;
1020 }
1021 else
1022 {
1023 previous_jittered_x = previous_marker_position->x;
1024 previous_jittered_z = previous_marker_position->z;
1025 }
1026
1027 marker_entry->facing_angle = Math_CalculateAtan2FP12(
1028 lateral_offset_z + (uint32_t)marker_entry->position.z - previous_jittered_z,
1029 (uint32_t)marker_entry->position.x + (uint32_t)marker_entry->lateral_offset_x - previous_jittered_x);
1030 marker_index = saved_marker_index;
1031 previous_marker_position_saved = &marker_entry->position;
1032 Trail_BoneQueue[marker_index].spawn_frame = next_spawn_frame;
1033 next_spawn_frame += 5;
1034 }
1035 else
1036 {
1037 if ((uint32_t)marker_timestamp + TRAIL_MARKER_LIFETIME_FRAMES <= (uint32_t)g_frameCounter)
1038 {
1039 Trail_BoneQueue[marker_index].spawn_frame = next_spawn_frame;
1040 next_spawn_frame += 5;
1041 }
1042
1043 int32_t marker_path_segment = (uint32_t)marker_entry->segment_index;
1044
1045 previous_marker_position_saved = &marker_entry->position;
1046 remaining_segment_distance = 0xffffffff;
1047 next_node = &Trail_BonePathNodes[marker_path_segment + 1];
1048 path_node = &Trail_BonePathNodes[marker_path_segment + 1];
1049 }
1050
1051 marker_index += 1;
1052 saved_marker_index = marker_index;
1053
1054 if (marker_index >= 5)
1055 return;
1056
1057 previous_marker_position = previous_marker_position_saved;
1058 }
1059}
@ ACTOR_ANIMATION_NO_BONE
Definition constants.h:109
#define ACTOR_BEHAVIOR_MOVEMENT_LOCKED
Definition constants.h:16
#define ACTOR_BEHAVIOR_DESTROY_AFTER_ANIMATION
Definition constants.h:28
#define ACTOR_BEHAVIOR_GROUND_TILT_ENABLED
Definition constants.h:21
@ ACTOR_OBJECT_RUNTIME
Definition constants.h:143
#define ACTOR_BEHAVIOR_BYPASS_COLLISION
Definition constants.h:18
struct Actor_State * Actor_CloneTemplateWithTemplateRelativeFixups(struct Actor_State *template_actor, struct Actor_State **list_head)
Definition lifecycle.c:311
int32_t Actor_GetAnimSeqIndex(struct Actor_State *actor)
Definition animation.c:519
bool Animation_ProcessController(struct Material_Node **material_nodes, Animation_PackedControllerState *packed_controller_state_in_out, int32_t frame_count_q12)
Definition controller.c:133
#define g_boneTrailPathBuffer_Z
Definition globals.h:52
#define g_boneTrailPathNodes
Definition globals.h:46
#define g_boneTrailPathCount
Definition globals.h:73
#define g_boneTrailTimer
Definition globals.h:37
#define g_boneTrailPathBuffer_Z1
Definition globals.h:61
#define g_boneTrailAnimTime
Definition globals.h:58
#define g_boneTrailPathNodeCount
Definition globals.h:31
#define g_boneTrailTargetPosition
Definition globals.h:55
#define g_boneTrailPathBuffer_Y
Definition globals.h:49
#define g_cameraTransformMatrix
Definition globals.h:81
struct Actor_State * Component_SpawnFromCollisionRecord(struct Actor_State *owner_actor, struct Actor_State *target_actor, struct Component_CollisionRecord *collision_record)
Definition lifecycle.c:54
#define Projectile_LiveActorListHead
Definition globals.h:15
#define ENTITY_FLAG_NAVIGATION_GOAL_ENABLED
Definition constants.h:23
#define ENTITY_FLAG_RESTORE_DEFAULTS
Definition constants.h:18
#define PLAYER_MAX_HEALTH
Definition constants.h:42
#define GAME_TRANSITION_FADE_COUNTDOWN
Definition constants.h:25
#define GAME_TRANSITION_COLOR_FADE
Definition constants.h:30
@ GAME_MODE_GAMEPLAY_3D
Definition enums.h:38
#define Game_FrameTransitionFlags
Definition globals.h:47
#define g_currentGameMode
Definition globals.h:74
void Graphics_SetPolygonUVs(struct Scene_Node *node, struct Graphics_Render_PolygonBatchRecord *out_batch, struct Material_TableEntry *polygon_data, int16_t uv_index_or_sentinel, struct Mesh_RuntimeVertex **polygon_vertices)
Definition meshes.c:335
#define g_polygonBatchRecords
Definition globals.h:290
#define Graphics_WindowWidth
Definition globals.h:140
#define render_list_state
Definition globals.h:152
#define Graphics_WindowHeight
Definition globals.h:143
#define INPUT_BUTTON_ACTION_3
Definition constants.h:10
#define g_inputStateCurrentP1
Definition globals.h:72
#define g_levelRenderDistanceQuarter
Definition globals.h:121
#define g_levelRenderDistance
Definition globals.h:115
#define MATERIAL_DEPTH_SORT
Definition constants.h:39
#define MATERIAL_BLEND_ENABLED
Definition constants.h:29
int32_t Math_SqrtFP12(uint32_t value)
void Math_MulMat3x3Q12(struct Math_Matrix3x3I16 *out_matrix, struct Math_Matrix3x3I16 const *right_factor, struct Math_Matrix3x3I16 const *left_factor)
Definition matrices.c:11
int16_t Math_CalculateAtan2FP12(int32_t y, int32_t x)
uint32_t Math_GenerateRandom(uint32_t range)
#define g_renderWorldTransformPtr
Definition globals.h:27
#define NAVIGATION_ENTITY_GOAL_COUNT
Definition constants.h:5
#define NAVIGATION_ENTITY_GOAL_FIRST
Definition constants.h:4
#define pkg_resource_current_level_data
Definition globals.h:117
#define POWERUP_ENTRY_COLLECTED
Definition constants.h:6
#define POWERUP_ENTRY_DISABLED
Definition constants.h:7
#define POWERUP_ENTRY_TRAIL_TARGET_PENDING
Definition constants.h:11
@ POWERUP_INVENTORY_FIRST
Definition constants.h:17
@ POWERUP_HEALTH_FIRST
Definition constants.h:16
int64_t __ftol_msvc(long double value)
uint8_t collision_class
Definition types.h:435
int16_t facing_current
Definition types.h:447
uint8_t transition_phase
Definition types.h:434
struct Mesh_RuntimeVertex * runtime_vertex_array
Definition types.h:397
uint8_t movement_handler_index
Definition types.h:433
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
int32_t behavior_flags
Definition types.h:407
void * record_ptr
Definition types.h:477
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
Definition types.h:118
uint8_t trail_count
Definition types.h:182
struct Component_TrailObject * trail_chain_ptr
Definition types.h:184
uint16_t attachment_joint_index
Definition types.h:44
struct Component_Definition * definition
Definition types.h:43
int16_t segment_index
Definition types.h:241
struct Trail_Segment * segment_array
Definition types.h:242
uint8_t max_segments
Definition types.h:233
uint8_t processed_flag
Definition types.h:234
uint8_t expiry_countdown
Definition types.h:235
struct Math_Vec3I32 node_view_translation
Definition types.h:679
struct Math_Matrix3x3I16 node_view_matrix
Definition types.h:677
struct Graphics_Render_ScreenVertexI16Z screen_vertices[0x4]
Definition types.h:512
struct Material_RuntimeDescriptor * texture_desc
Definition types.h:496
struct Graphics_Render_PolygonBatchRecord * next_in_bucket
Definition types.h:511
struct Math_Vec3F view_vertices[0x4]
Definition types.h:513
struct Graphics_Render_ScreenVertexI16Z::@276010272006271151340046314217100172252315123166::@167176104245357063215260323150214177117323053225 screen
struct Trail_Entry * trail_list
Definition types.h:56
int16_t controller_count
Definition types.h:14
struct MaterialControllerSlot ** controller_slot_array
Definition types.h:15
int16_t elements[9]
Definition types.h:173
struct Math_Vec3I32 translationQ6
Definition types.h:562
struct Math_Matrix3x3I16 rotationQ12
Definition types.h:560
float z
Definition types.h:448
float y
Definition types.h:447
float x
Definition types.h:446
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
Definition types.h:9
struct Powerup_Entry::@336143272047254075051102357366017247347220271357 pos
int32_t y
Definition types.h:21
int32_t x
Definition types.h:20
int32_t z
Definition types.h:22
uint8_t powerup_type
Definition types.h:14
uint8_t flags
Definition types.h:15
struct TrailProjectedPoint width
Definition effects.c:205
struct TrailProjectedPoint start
Definition effects.c:204
struct Graphics_Render_ScreenVertexI16Z screen
Definition effects.c:199
struct Math_Vec3F view
Definition effects.c:198
struct Math_Vec3I32 position
Definition types.h:77
int32_t segment_index
Definition types.h:71
int16_t facing_angle
Definition types.h:74
uint32_t spawn_frame
Definition types.h:76
int32_t lateral_offset_z
Definition types.h:73
int32_t lateral_offset_x
Definition types.h:72
Definition types.h:37
void * data_ptr
Definition types.h:40
struct Material_Node ** material_nodes
Definition types.h:56
struct Trail_Segment * segment_array
Definition types.h:61
struct MaterialControllerGroup * controller_group
Definition types.h:58
int16_t segment_index
Definition types.h:60
struct Material_TableEntry * material
Definition types.h:57
int32_t width_step_q12
Definition types.h:51
int32_t intensity_step_q12
Definition types.h:50
int32_t active
Definition types.h:93
struct Math_Vec3I16 end
Definition types.h:97
struct Math_TransformQ12Q6 world_transform
Definition types.h:94
struct Math_Vec3I16 start
Definition types.h:95
#define TRAIL_SORT_BUCKET_MAX
Definition constants.h:12
#define TRAIL_BONE_QUEUE_CAPACITY
Definition constants.h:17
#define TRAIL_LAST_SORTED_BUCKET
Definition constants.h:13
#define TRAIL_BONE_PATH_SEARCH_TICKS
Definition constants.h:16
#define TRAIL_BONE_WARMUP_TICKS
Definition constants.h:15
#define TRAIL_SKIP_SAMPLE_AND_EXPIRY
Definition constants.h:6
#define TRAIL_MARKER_LIFETIME_FRAMES
Definition constants.h:11
#define TRAIL_BONE_LIFETIME_FRAMES
Definition constants.h:10
static void project_trail_edge(const struct Trail_Segment *segment, int32_t width, struct TrailProjectedEdge *edge)
Definition effects.c:252
struct Actor_State * Trail_SpawnFromEntry(struct Actor_State *actor, int32_t trail_index)
Definition effects.c:124
static int32_t trail_screen_coordinate(int32_t view, int32_t scale, int32_t extent)
Definition effects.c:219
void Trail_UpdateAndRenderActorTrails(struct Actor_State *actor)
Definition effects.c:44
static int32_t trail_depth_bucket(const struct TrailProjectedEdge *previous, const struct TrailProjectedEdge *current)
Definition effects.c:270
static uint32_t trail_fade(uint32_t rgb, int32_t scale)
Definition effects.c:295
void Trail_RenderAnimated(struct Trail_RenderRuntimeView *trail, struct Actor_State *actor, struct Submesh_RenderSpan *span)
Definition effects.c:304
static void project_trail_point(const struct Math_Vec3I16 *point, struct TrailProjectedPoint *out)
Definition effects.c:224
static int32_t trail_translation(const int16_t *row, const struct Math_Vec3I32 *position)
Definition effects.c:208
int32_t Trail_CheckBoneAvailable()
Definition effects.c:388
static int32_t trail_view_coordinate(const int16_t *row, const struct Math_Vec3I16 *point, int32_t origin)
Definition effects.c:213
static uint32_t trail_gray(int32_t intensity_q12)
Definition effects.c:288
char Trail_UpdateEffect(struct Component_TrailObject *trail, const struct Actor_State *actor, const struct Graphics_Render_PolygonRenderRef *polygon_ref, char active)
Definition effects.c:72
void Trail_ResetBone()
Definition effects.c:400
void Trail_UpdateAndRenderBone(struct Actor_State *actor, struct Math_Vec3I32 *movement_vec)
Definition effects.c:413
static int16_t trail_width_coordinate(int16_t start, int16_t end, int32_t fraction)
Definition effects.c:247
char Trail_UpdateEffect(struct Component_TrailObject *trail, struct Actor_State const *actor, struct Graphics_Render_PolygonRenderRef const *polygon_ref, char active)
Definition effects.c:72
int32_t Trail_FindBonePath(struct Math_Vec3I32 *start_pos, struct Nav_Network *nav_network, int32_t skip_dynamic_targets)
Definition geometry.c:27
#define Trail_BoneQueue
Definition globals.h:12
#define Trail_ResetBone_CurrentPathNodeSelector
Definition globals.h:9
#define Trail_BonePathNodes
Definition globals.h:13
#define g_nodeViewTranslationY
Definition values.h:774
#define g_renderingStateFlag
Definition values.h:627
#define g_frameCounter
Definition values.h:501
#define g_currentPolygonBatchIndex
Definition values.h:768
#define g_nodeViewTranslationZ
Definition values.h:777
#define g_nodeViewTranslationX
Definition values.h:771