add obj_get_model_id function

This commit is contained in:
Reonu
2021-09-17 00:18:52 +03:00
parent f9e2070eb1
commit fc30f1bb1e
3 changed files with 16 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin
- Apply_patch.sh improved - Apply_patch.sh improved
- Removed the ifdef hell in `file_select.c` and `ingame_menu.c` - Removed the ifdef hell in `file_select.c` and `ingame_menu.c`
- Added Blake's custom function for object model stuff: `obj_set_model` and `obj_has_model` - Added Blake's custom function for object model stuff: `obj_set_model` and `obj_has_model`
- Added function to get the model ID from an object: `obj_get_model_id` (by Arceveti)
- The "far" variable is now u16, allowing you to increase the farclip (the max distance at which geometry is rendered). However, when increasing the farclip, make sure to increase the nearclip by the same ratio, or rendering will break on console and LLE plugins. - The "far" variable is now u16, allowing you to increase the farclip (the max distance at which geometry is rendered). However, when increasing the farclip, make sure to increase the nearclip by the same ratio, or rendering will break on console and LLE plugins.
- Many general use defines for object struct members, meant for use in custom object behaviors. Check `object_fields.h` for more info on this. (By MrComit) - Many general use defines for object struct members, meant for use in custom object behaviors. Check `object_fields.h` for more info on this. (By MrComit)
- Included `actors/group0.c` in `behavior_data.c` - Included `actors/group0.c` in `behavior_data.c`

View File

@@ -2911,7 +2911,7 @@ void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 o
} }
#endif #endif
// Extra functions for ultrasm64-extbounds // Extra functions for HackerSM64
void obj_set_model(struct Object *obj, s32 modelID) { void obj_set_model(struct Object *obj, s32 modelID) {
obj->header.gfx.sharedChild = gLoadedGraphNodes[modelID]; obj->header.gfx.sharedChild = gLoadedGraphNodes[modelID];
} }
@@ -2919,5 +2919,15 @@ void obj_set_model(struct Object *obj, s32 modelID) {
s32 obj_has_model(struct Object *obj, u16 modelID) { s32 obj_has_model(struct Object *obj, u16 modelID) {
return (obj->header.gfx.sharedChild == gLoadedGraphNodes[modelID]); return (obj->header.gfx.sharedChild == gLoadedGraphNodes[modelID]);
} }
// End of ultrasm64-extbounds stuff
u32 obj_get_model_id(struct Object *obj) {
s32 i;
for (i = 0; i < MODEL_ID_COUNT; i++) {
if (obj->header.gfx.sharedChild == gLoadedGraphNodes[i]) {
return i;
}
}
return 0;
}
// End of HackerSM64 stuff

View File

@@ -298,9 +298,10 @@ void cur_obj_spawn_loot_blue_coin(void);
void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY); void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 offsetY);
#endif #endif
// Extra functions for ultrasm64-extbounds // Extra functions for HackerSM64
void obj_set_model(struct Object *obj, s32 modelID); void obj_set_model(struct Object *obj, s32 modelID);
s32 obj_has_model(struct Object *obj, u16 modelID); s32 obj_has_model(struct Object *obj, u16 modelID);
// End of ultrasm64-extbounds stuff u32 obj_get_model_id(struct Object *obj);
// End of HackerSM64 stuff
#endif // OBJECT_HELPERS_H #endif // OBJECT_HELPERS_H