Commit graph

927 commits

Author SHA1 Message Date
Matt Penny 1d0b22df61 Generate dynamic model lists with CMake, + refactor
* When building with CMake, dynamic model lists are now generated
* Factored common code out of generate_*_list.js files to deduplicate
* Better separated generated model lists from main game code
    `dynamic_asset_data.c` and `dynamic_animated_asset_data.c`
    previously #included the corresponding generated headers, and
    `dynamic_asset_loader.c` declared externs for the contents.

    This messiness was likely done so the generated code would be built
    automatically (the Makefile globs all C files under `src/`).

    Now, model list data is output to C source files which are built
    explicitly. This, with some refactoring, allows the previously
    mentioned source files and externs to be removed.

    This is a bit hacky in the Makefile but will be automatic under
    CMake by using target properties.
* Reorganized some files under `tools/`
2024-10-05 21:11:49 -04:00
Matt Penny e1e6a53aa6 Convert models during CMake build
No generation of dynamic model lists yet
2024-10-05 01:54:55 -04:00
Matt Penny 1e8a4f5458 Remove empty linked list files 2024-10-05 01:24:56 -04:00
Matt Penny 2e6f8ac86b Reflect proper default scene scale in defs.h
This value is set when compiling anyway, but this change makes the value
match for consistency.

Now that the default is the actual intended value, it doesn't need to be
overridden in the Makefile, but since scene scale needs to be passed to
skeletool regardless I'm going to keep the preprocessor define too so
they don't get out of sync.
2024-10-05 01:24:56 -04:00
Matt Penny 6a14db3a16 Start to hook up code generation with CMake builds
Automatically generate material, sound, and level data.

Generated code is not currently linked.
2024-09-26 23:06:10 -04:00
Matt Penny 51e7e001a5 Link to libultra for CMake builds
Libultra include directory and library path are now found dynamically and
saved in a CMake cache variable so they can be overridden by users.

The game now links to libultra. Most linker errors are now due to lack of
integration with generated code dependencies.
2024-09-26 00:36:44 -04:00
Matt Penny bc2052527c Generate game version for CMake builds and fix generated level names
With CMake, the game version is stored in a generated header file so
dependencies on it are kept track of automatically.

The game now compiles when using CMake but does not link.

Generated code dependencies are not hooked up yet and corresponding
targets need to be built manually.
2024-09-25 22:24:16 -04:00
Matt Penny 9e633b868b Work on CMake compilation
About half of the source files compile.
Need to hook up generated code, compiler definitions, and dependencies.
2024-09-24 01:27:18 -04:00
Matt Penny 429dc0bd91 Add version text to landing menus
If the current commit has a tag, the tag name is used as the version.
Otherwise, the short hash of the current commit is used.
2024-08-20 21:05:29 -04:00
Matt Penny da028cd405 Update credits with link to current repo 2024-08-20 19:59:36 -04:00
Matt Penny ab56ffb380 Add can_see argument to whitelist visible rooms
Useful for room shapes which cannot be handled by standard visibility
checks.

Normally this can be addressed with additional rooms and doorways, but
sometimes a room is required to be a complex shape (for example, to
accomodate animated static geometry).

These instances should be few and far between, so leaving this as an
opt-in feature that can be used during level authoring.
2024-08-20 19:52:50 -04:00
Matt Penny d5a1c302b1 Fix portal indicator HUD not working through multiple doorways
* Doorway normals now always point toward room A. This was intended
  and code was written for it, but typos prevented it from working.
* Consistent doorway directions allowed resurrection of previous
  collisionSceneRaycastDoorways() implementation
2024-08-20 17:37:29 -04:00
Matt Penny 9822ffeac9 Support precise (i.e., rotated) culling of static geometry (#73)
Standard culling is quite coarse, for performance reasons:
* Only uses axis-aligned bounding boxes
* One visible object in a BVH node will make all others in the same node visible

These properties allow the bounding boxes of rotated objects to clip through
the back of portals to be considered visible, causing improper rendering.

This commit introduces a new optional argument for `@static` level
objects: `precise_culling`. Static geometry marked for precise culling
will be culled based on its exact (i.e., rotated) bounding box, in the
same way dynamic/animated geometry is.

Precise culling is more expensive than standard culling so it is opt-in.
It is intended only for the few situations that can hit the edge cases
described above.
2024-07-26 18:47:58 -04:00
Matt Penny 3a2efced6d Fix crash on savefile load if player is far from start
The player's bounding box was not reinitialized on save file load,
causing the collision detection area to include the space between the
level's starting point and their current position.

In large levels (i.e., chamber 15) when far away from the start, this
caused the internal collider limit to be exceeded resulting in a buffer
overflow and crash.
2024-07-19 20:13:17 -04:00
Matt Penny f67ba7a5cc Fix activated ball catcher save file serialization
Previously, all activated catchers would reference the same ball
when saving, causing position and signal issues if the referenced
ball's launcher was in use.

Fixes glitchy ball movement in chamber 15 final room.
2024-07-17 23:46:31 -04:00
Matt Penny ef179ec553 Finishing touches on friction and jump boost 2024-07-13 02:20:01 -04:00
Matt Penny 9e34f89ccc Push objects out of portals when forcibly closed
E.g., cutscenes, player death, fizzled, touched by moving surface, etc.

Keeps objects in bounds.
2024-07-07 20:47:14 -04:00
Matt Penny 2eb881b59f Better limit jump boost speed 2024-07-07 20:23:57 -04:00
Matt Penny 1211edb383 Forward/backward velocity boost on jump (#8) 2024-07-05 00:28:16 -04:00
Matt Penny 5fa1a4c4a1 Push objects out of portal when opposite one changes
Previously only pushed out when current portal changed.
2024-07-04 00:26:51 -04:00
Matt Penny e6fde28d16 Make fling opposition check axis-aligned
The previous implementation handled flings in any horizontal direction.
However, this allowed moving against flings by first moving slightly
perpendicularily to them. In other words, the fling direction could be
changed midair allowing free movement relative to the original direction.

One way to solve this is by saving the initial fling direction (direction
of travel while in air and FLING_THRESHOLD_VEL is reached). For simplicity
and to minimize errors, just consider movement axes individually. The
game's levels only permit axis-aligned flings anyway.
2024-07-03 23:09:18 -04:00
Matt Penny c521da5f0c Prevent moving against flings 2024-07-03 22:29:56 -04:00
Matt Penny 847d9e8d70
Better match movement physics of original game (#77)
Source-like acceleration, friction, air control, and portal funneling.

Also improve anchoring to moving platforms.
2024-06-28 16:17:49 -04:00
Matt Penny c8ab62103e Update player position when dead
Fixes getting stuck in the air on death. Only velocity is applied -
player input is disabled..
2024-06-18 00:33:56 -04:00
Matt Penny 872c436be2 Refactored and simplified more player update logic
* Moved player sound code from scene.c to player.c
* Moved platform position/velocity update to playerUpdateFooting(),
  which is where the other related platform code is
* Moved player footstep state update to playerUpdateFooting()
* Created separate function for processing player input
* Created separate functions for movement and acceleration
* Removed some redundant code

With acceleration now separate, movement physics are ready to be
updated.
2024-06-17 23:52:59 -04:00
Matt Penny 7964ae17db Update collision docs and clarify player roll correction edge case in comment 2024-06-12 02:09:47 -04:00
Matt Penny 925e66b20a Fix some portal raycast and player footing collision
* Doors correctly block portals again
* Elevator floors once again collide with portals and the player
* Buttons and switches now block portals
2024-06-12 01:47:23 -04:00
Matt Penny 09c4bb99ea Refactor player camera update code into separate function
Work toward simplifying playerUpdate() to make it easier to maintain.
In the short term, this will help for updating movement physics.
2024-06-12 00:08:41 -04:00
Matt Penny ccd2901659 Increase dynamic collision object limit to 64 + raycasting optimizations
Dynamic object pairwise collision should be efficient enough to handle
additional objects, since only those with intersecting bounding boxes are
compared further.

Optimized raycasting by only considering dynamic collision objects in
rooms that the ray passes through. Previously, all were checked with
some distance calculations at the very least (to determine if intersection
was impossible). Raycasts are done by player grabs, player footing updates,
and portal HUD/firing.

This should be sufficient. Further optimizations can be investigated if
needed going forward.
2024-06-08 22:32:37 -04:00
Matt Penny b29b5c2b8d Autogenerate static collision for fizzler sides (#70)
Eliminates the two stationary dynamic collision objects that were
previously used.

This change refactors entities.lua and collision_export.lua to support
autogenerated static collision for any object which may need it in the
future.
2024-06-06 23:39:56 -04:00
Matt Penny 93d3d7c602 Simplify tiled fizzler height calculations and name variables more clearly 2024-06-02 17:53:54 -04:00
Matt Penny 3ed8552a9c Support vertically tiled fizzlers
Reduces dynamic object and dynamic collision object count.
2024-05-30 00:13:01 -04:00
Matt Penny 1e8275eec3
Chamber 15 - first pass (#39) (#69)
* started on chamber 15

* fizzler width can now be scaled via blender object's scale.x

* fix fizzler rendering radius (remember, fizzlers are per default 2x2, still their internal width height was 1x1?)

* chamber 15 first room functionally complete

* chamber 15: first room decor

* finished first room of chamber 15

* test chamber 15 second room WIP

* chamber15 hallway from room 2 to room 3 (WIP) and more progress on room 2

* test chamber 15: added observation room to room2, added voice lines add the beginning

* test chamber 15: finishing room 2

* enable "new game" menu entry for chamber 15 & boot into the intro menu again instead of straight into chamber 15

* Start on shamber 15 hazard hallway

Hallway is modeled with collision. No platforms.

* Decals and platform + light cutouts for chamber 15 hazard hallway

* Animate one moving platform in chamber 15 hazard hallway

This one animation is ~19 KB. Look at optimizing.

* Add material for water hazard wall

* Use water hazard wall material in chamber 15

* Start modelling final room of chamber 15

* Chamber 15 final room - side rooms

* Chamber 15 final room - pistons and exit

* Chamber 15 final room - observation room

* Chamber 15 final room - ball launcher and catcher

* Chamber 15 final room - ball trap and indicator lights

* Chamber 15 final room - ball trap doors

* Chamber 15 final room - collision

* Chamber 15 final room - animations and triggers

* Chamber 15 - escape hatch

* Chamber 15 - finish final room

* Chamber 15 - start on room 3

* Chamber 15 - main room 3 layout and collision

* Fix UV translation

Do not translate minimum coordinates, otherwise the translation will be
cancelled out.

* Chamber 15 - room 3 stair room

* Chamber 15 - room 3 dividers and ball launcher/catcher

* Chamber 15 - room 3 finishing touches

* Observation room decor
* Triggers
* Indicator lights
* Decals

* Chamber 15 - merge beginning and end

* Chamber 15 - fix room boundaries

---------

Co-authored-by: Deconimus <pascal.sielski@gmx.de>
Co-authored-by: Deconimus <Deconimus@users.noreply.github.com>
2024-05-28 01:53:02 -04:00
Matt Penny 134be543ba Fix typo: frustrum -> frustum 2024-05-28 01:44:52 -04:00
Matt Penny 220dd585b4 Improve room visibility culling
When determining room visibility, the camera's frustum was previously
used for all recursive doorway checks, meaning rooms were considered
visible even if they were occluded. With the right level and camera
angle, all rooms could be considered visible at once.

Now, for each recursive check, a new frustum is created from the previous
doorway's bounds.

This helps significantly in larger levels, but there is still room for
improvement. Each new frustum is not clipped to the previous, and so it
is still possible for unseen rooms to be included.

It's important to consider performance here. Some checks may be too
expensive for realtime. At a minimum, a worthwhile improvement is to
precompute at compile time which rooms are potentially visible from a
given room. At runtime, other rooms can be quickly skipped.
2024-05-28 01:44:52 -04:00
Giacomo Garbin 6c791e0ae0
Further abstract time types and functions. (#68)
* replace OSTime with Time
* replace osGetTime with timeGetTime
* replace OS_CYCLES_TO_USEC with timeMicroseconds
* replace OS_CYCLES_TO_NSEC with timeNanoseconds

also
* lastReportStart of ProfileData was used to store both cycles and microseconds, now it stores only microseconds
* fix typo: ns instead of us
2024-05-28 00:59:29 -04:00
Giacomo Garbin 855f798a18
Decouple time interface from libultra (#66)
* Wrap OSTimer usage into sleep function.

* Remove unused gLastTime.

This makes time.h independent from libultra, so let's rename time.c to time_libultra.c.

TODO: should we move time.h and time_libultra.c to the src/system folder?

* Add time unit to macro name.

* Move time initialization call to main function.

* Move time.h and time_libultra.c to src/system folder.
2024-05-17 01:09:08 -04:00
Giacomo Garbin e12354556f
Move the definition of MatrixFromBasisL to debug_render.c which is the only file that uses it. (#64) 2024-05-08 20:30:27 -04:00
Matt Penny 64e2f0e5bf Doors block energy balls 2024-05-05 18:31:34 -04:00
Matt Penny fa26ac449e Support rotated doors and remove some unused door code 2024-05-05 18:26:30 -04:00
Matt Penny aecbda3071 Fix debug include for libultra controller 2024-05-04 12:07:36 -04:00
Giacomo Garbin 167269c5d1
Decouple controls interface from libultra. (#60)
* Decouple controls interface from libultra.

* Use enums instead of defines for constant values.

* Get both controller stick axes with a single function call.

* Move controller .h\.c files to src/system folder and rename controller.c to controller_libultra.c.

* Adhere to enum and struct naming convention of the codebase.

* Fix typo: the N64 controller only has one analog stick.
2024-05-02 17:49:38 -04:00
Deconimus 247e66fb62
Grab rotation flags (#58)
* introduced "enum GrabRotationFlags" for type-based grab behavior and added grab_rotation.c/.h to offload grabRotation code from player.c

* grab_rotation snap cube normals fix

* grab_rotation: some cleanup

* grab_rotation.c: simplify grabRotationInitBase + some cleanup
2024-04-22 18:44:18 -04:00
Matt Penny bf5b8e0d28
Merge pull request #47 from GiacomoGarbin/replace_libnustd_with_glibc
Use newlib instead of libnustd.
2024-04-12 19:01:12 -04:00
Matt Penny 7005450479 Fix indicator lights for active signals across save/load 2024-04-11 22:44:03 -04:00
Matt Penny 73e81b3308
Merge pull request #56 from Deconimus/issue41_fizzler_frame_collision
Add collision for fizzler frames
2024-04-11 19:54:38 -04:00
Matt Penny a551de9890 Minor fizzler frame collision cleanup 2024-04-11 19:44:42 -04:00
Deconimus 8676845cd7 tweak y offset minimum limit to match original game (and due to issue #52) 2024-04-06 23:10:56 +02:00
Matt Penny 8abbcb0407 Slightly tweak max grab height
Original game allows a height of ~1 wall panel
2024-04-05 21:09:06 -04:00
Matt Penny 7129deec4a
Merge branch 'master' into issue52_grab_y_offset 2024-04-05 20:31:11 -04:00