mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-06-21 00:31:58 -04:00
44db9bab77
* initial work
* more work
* progress
* Fixed slow fps
* Add Lywx changes
* Interp Works
* Test default tick/logic update
* Added missing include (#202)
* Added missing include
* More missing includes
---------
Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
* test
* Revert "test"
This reverts commit 1a810d74cc.
* Interp Item box
* Actually interpolate item box
* fix clouds
* interp player?
* Test 2
* Fix mistake
* tag and fix item boxes
* tag fake item box and whatever func_800696CC is
* these aren't needed
* tag karts
* Slightly better falling rocks(still needs work)
* Tag Smoke and Dust
* Removed unneeded code from falling_rock
* tag whatever func_80051ABC is
* add missing rotate x coord
* GrandPrixBallon/kart shadow
* Green shells tag, and added comments I neglected to add before.
* doesn't compile on win
* Fixes
* Disabled camera interpolation
* Balloons fixes
* progress
* set_transform_matrix compiles
* Compile setTransformMatrix
* More transforms interp
* Add more interps
* matrix
* Matrix multi interp
* Fix interpolation camera bug
* Missing includes needed for Linux.
* Excluded access to HM64 Labs on Switch.
* interpolation tags for various objects
* Bowser castle statue flame interpolated.
* tag hedgehogs
* cloud interpolation
* Interpolated smoke particles from shells
* cloud interpolation refactor
* Interpolated snowflakes
* Interpolated penguins, also added comment tags to places I missed.
* tag Snowman interpolation
* Interpolated player reflection(sherbet land)
* Forgot to uncomment stuff while testing
* better tag
* tag leaves
* Set the default FPS to 30
* tag hud
* Fixed "Match Refresh Rate" option
* adjust draw distance
* remove innecessary rock tag
* rag rocks
* better tag
* Tagged player rank placement in HUD
* Tagged Bat, Boos, and TrashBin(Banshee Boardwalk objects)
* Refactor render_screens and fix editor raycast
* better object interpolation
* shift is not needed here
* fix tag
* fix tags
* mole comments
* comment
* Changed how shell flames are interpolated.
* interpolated ended scene fireworks.
* Tagged star particles in the ending scene
* Shell flames handled better.
* this isn't needed
* Fix multiplayer cameras
* Fixed loading battle maps.
* Tagged battle balloons
* Some fixes for battle mode
* No longer needed changes toAFinishline with the changes mega made.
* Tag finishline
* fix to make it compile with cmake 3.31
* changed mtxf_multiplication() to fix vert explosion in Desert & DK parkway.(provided by Coco.)
* fix memory leaks, avoid invalidate texture (#207)
* Fixed macos
* More stupid fixes
* update with main and update torch and lus and enable action on this branch
* Update FrameInterpolation.h
* Update FrameInterpolation.cpp
* fix some memory leak
* Update torch
* Update torch
* update torch and lus
* reduce texture import
* don't use fork of torch and lus
* Update torch
* Update torch
---------
Co-authored-by: Lywx <kiritodev01@gmail.com>
* Refactor World::Courses to unique_ptr (#211)
* wip course unique ptr
* Track unique_ptr : This probably compiles
* Finish impl Courses as unique_ptr
* Fix error
* Fixes
* More fixes
* Cleanup
* Remove old vars
---------
Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
* particle boat and train
* fix player particle interpolation
* add modify interpolation target fps in menu
* fix windows
* Update libultraship
* Fix logo interp
* Interp SetTextMatrix
* Fix freecam camera
* Clarify comment
* Clarify func
* fix linux compilation
* Update Thwomp.cpp
* Update Thwomp.h
* Update render.inc.c
* Update render.inc.c
* Update gbiMacro.c
* interp falling rock shadow
* Revert change that has no explanation
* Update code_80057C60.c
* Update code_80057C60.c
* Update GrandPrixBalloons.cpp
* Update Lakitu.cpp
* Update framebuffer_effects.c
* Update render_courses.c
---------
Co-authored-by: Sonic Dreamcaster <alejandro.asenjo88@gmail.com>
Co-authored-by: KiritoDv <kiritodev01@gmail.com>
Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com>
Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Co-authored-by: coco875 <59367621+coco875@users.noreply.github.com>
Co-authored-by: coco875 <pereira.jannin@gmail.com>
187 lines
5.8 KiB
C
187 lines
5.8 KiB
C
#include <libultraship.h>
|
|
#include <macros.h>
|
|
#include <mk64.h>
|
|
#include "math_util.h"
|
|
#include "animation.h"
|
|
#include "memory.h"
|
|
#include <main.h>
|
|
#include <libultra/gbi.h>
|
|
#include "code_80057C60.h"
|
|
#include "engine/Matrix.h"
|
|
#include "port/interpolation/FrameInterpolation.h"
|
|
|
|
Vec3s sOriginalPosAnimation;
|
|
s16 isNotTheFirst;
|
|
s16 sMatrixShouldNotPop;
|
|
s16 sMatrixStackSize;
|
|
|
|
void convert_to_fixed_point_matrix_animation(Mtx* dest, Mat4 src) {
|
|
#ifdef AVOID_UB
|
|
// Avoid type-casting which is technically UB by calling the equivalent
|
|
// guMtxF2L function. This helps little-endian systems, as well.
|
|
guMtxF2L(src, dest);
|
|
#else
|
|
s32 asFixedPoint;
|
|
s32 i;
|
|
s16* a3 = (s16*) dest; // all integer parts stored in first 16 bytes
|
|
s16* t0 = (s16*) dest + 16; // all fraction parts stored in last 16 bytes
|
|
f32* t1 = (f32*) src;
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
asFixedPoint = *t1++ * (1 << 16); //! float-to-integer conversion responsible for PU crashes
|
|
*a3++ = GET_HIGH_S16_OF_32(asFixedPoint); // integer part
|
|
*t0++ = GET_LOW_S16_OF_32(asFixedPoint); // fraction part
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void mtxf_translate_rotate2(Mat4 dest, Vec3f pos, Vec3s angle) {
|
|
|
|
FrameInterpolation_RecordMatrixPosRotXYZ(&dest, pos, angle);
|
|
|
|
f32 sx = sins(angle[0]);
|
|
f32 cx = coss(angle[0]);
|
|
|
|
f32 sy = sins(angle[1]);
|
|
f32 cy = coss(angle[1]);
|
|
|
|
f32 sz = sins(angle[2]);
|
|
f32 cz = coss(angle[2]);
|
|
|
|
dest[0][0] = cy * cz;
|
|
dest[0][1] = cy * sz;
|
|
dest[0][2] = -sy;
|
|
dest[0][3] = 0.0f;
|
|
|
|
dest[1][0] = sx * sy * cz - cx * sz;
|
|
dest[1][1] = sx * sy * sz + cx * cz;
|
|
dest[1][2] = sx * cy;
|
|
dest[1][3] = 0.0f;
|
|
|
|
dest[2][0] = cx * sy * cz + sx * sz;
|
|
dest[2][1] = cx * sy * sz - sx * cz;
|
|
dest[2][2] = cx * cy;
|
|
dest[2][3] = 0.0f;
|
|
|
|
dest[3][0] = pos[0];
|
|
dest[3][1] = pos[1];
|
|
dest[3][2] = pos[2];
|
|
dest[3][3] = 1.0f;
|
|
}
|
|
|
|
void render_limb_or_add_mtx(Armature* arg0, s16* arg1, AnimationLimbVector arg2, s32 timeCycle) {
|
|
Vec3f pos;
|
|
Vec3s angle;
|
|
Mat4 modelMatrix;
|
|
s32 i;
|
|
s32 some_offset;
|
|
Gfx* model;
|
|
Gfx* virtualModel;
|
|
virtualModel = arg0->model;
|
|
if (isNotTheFirst == 0) {
|
|
for (i = 0; i < 3; i++) {
|
|
pos[i] = sOriginalPosAnimation[i] + arg0->pos[i];
|
|
}
|
|
isNotTheFirst += 1;
|
|
} else {
|
|
for (i = 0; i < 3; i++) {
|
|
pos[i] = arg0->pos[i];
|
|
}
|
|
}
|
|
for (i = 0; i < 3; i++) {
|
|
if (timeCycle < arg2[i].animation_length) {
|
|
some_offset = timeCycle;
|
|
} else {
|
|
some_offset = 0;
|
|
}
|
|
angle[i] = arg1[arg2[i].indexCycle + some_offset];
|
|
}
|
|
FrameInterpolation_RecordMatrixPush(modelMatrix);
|
|
mtxf_translate_rotate2(modelMatrix, pos, angle);
|
|
//convert_to_fixed_point_matrix_animation(&gGfxPool->mtxHud[gMatrixHudCount], modelMatrix);
|
|
sMatrixStackSize += 1;
|
|
// gSPMatrix(gDisplayListHead++, (&gGfxPool->mtxHud[gMatrixHudCount++]),
|
|
// G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
|
|
|
AddHudMatrix(modelMatrix, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
|
|
if (virtualModel != NULL) {
|
|
model = (virtualModel);
|
|
gSPDisplayList(gDisplayListHead++, model);
|
|
}
|
|
FrameInterpolation_RecordMatrixPop(modelMatrix);
|
|
}
|
|
|
|
void render_armature(Armature* animation, Animation* arg1, s16 timeCycle) {
|
|
UNUSED u32* temp;
|
|
s16* angle_array;
|
|
s32 some_offset;
|
|
AnimationLimbVector* animation_cycle_list;
|
|
s32 animation_type;
|
|
s32 someIndex;
|
|
|
|
angle_array = (arg1->angle_array);
|
|
animation_cycle_list = (arg1->animation_cycle_spec_vector);
|
|
sMatrixStackSize = 0;
|
|
isNotTheFirst = 0;
|
|
for (someIndex = 0; someIndex < 3; someIndex++) {
|
|
if (timeCycle < (*animation_cycle_list)[someIndex].animation_length) {
|
|
some_offset = timeCycle;
|
|
} else {
|
|
some_offset = 0;
|
|
}
|
|
sOriginalPosAnimation[someIndex] = angle_array[(*animation_cycle_list)[someIndex].indexCycle + some_offset];
|
|
}
|
|
animation_cycle_list++;
|
|
sMatrixShouldNotPop = 0;
|
|
do {
|
|
animation_type = animation->type;
|
|
switch (animation_type) { /* irregular */
|
|
case STOP_ANIMATION:
|
|
break;
|
|
case DISABLE_AUTOMATIC_POP_MATRIX:
|
|
sMatrixShouldNotPop = 1;
|
|
break;
|
|
case POP_MATRIX:
|
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
|
sMatrixStackSize -= 1;
|
|
break;
|
|
case RENDER_MODEL_OR_ADD_POS:
|
|
if (sMatrixShouldNotPop == 0) {
|
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
|
sMatrixStackSize -= 1;
|
|
}
|
|
render_limb_or_add_mtx(animation, angle_array, *animation_cycle_list, (s32) timeCycle);
|
|
sMatrixShouldNotPop = 0;
|
|
animation_cycle_list++;
|
|
break;
|
|
}
|
|
animation = (Armature*) ((uintptr_t*) animation + animation->size);
|
|
} while (animation_type != STOP_ANIMATION);
|
|
}
|
|
|
|
s16 render_animated_model(Armature* virtualArmature, Animation** virtualListAnimation, s16 animationIndex,
|
|
s16 timeCycle) {
|
|
Armature* armature;
|
|
Animation* animation;
|
|
Animation** listAnimation;
|
|
|
|
armature = (virtualArmature);
|
|
listAnimation = (virtualListAnimation); // Convert the array's address
|
|
animation = (listAnimation[animationIndex]); // Convert an array element's address
|
|
if (timeCycle >= animation->animation_length) {
|
|
timeCycle = 0;
|
|
}
|
|
render_armature(armature, animation, timeCycle);
|
|
timeCycle++;
|
|
if (timeCycle >= animation->animation_length) {
|
|
timeCycle = 0;
|
|
}
|
|
return timeCycle;
|
|
}
|
|
|
|
s16 get_animation_length(Animation** addr, s16 offset) {
|
|
Animation** item = (addr);
|
|
Animation* temp = (Animation*) ((void*) item[offset]);
|
|
return temp->animation_length - 1;
|
|
}
|