mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add collision_find_surface_on_ray()
This commit is contained in:
parent
2d8715b330
commit
c2177b4eec
9 changed files with 113 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ in_files = [
|
||||||
"src/pc/network/network_player.h",
|
"src/pc/network/network_player.h",
|
||||||
"include/behavior_table.h",
|
"include/behavior_table.h",
|
||||||
"src/pc/lua/smlua_obj_utils.h",
|
"src/pc/lua/smlua_obj_utils.h",
|
||||||
|
"src/pc/lua/smlua_misc_utils.h",
|
||||||
"src/game/object_helpers.c",
|
"src/game/object_helpers.c",
|
||||||
"src/game/obj_behaviors.c",
|
"src/game/obj_behaviors.c",
|
||||||
"src/game/obj_behaviors_2.c",
|
"src/game/obj_behaviors_2.c",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ in_files = [
|
||||||
'src/game/object_helpers.h',
|
'src/game/object_helpers.h',
|
||||||
'src/game/mario_step.h',
|
'src/game/mario_step.h',
|
||||||
'src/pc/lua/smlua_anim_utils.h',
|
'src/pc/lua/smlua_anim_utils.h',
|
||||||
|
'src/pc/lua/smlua_misc_utils.h',
|
||||||
'src/game/spawn_sound.h',
|
'src/game/spawn_sound.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -617,6 +617,11 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
- smlua_misc_utils.h
|
||||||
|
- [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
- smlua_obj_utils.h
|
- smlua_obj_utils.h
|
||||||
- [obj_get_first](#obj_get_first)
|
- [obj_get_first](#obj_get_first)
|
||||||
- [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
|
- [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
|
||||||
|
|
@ -11383,6 +11388,37 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
---
|
||||||
|
# functions from smlua_misc_utils.h
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
|
||||||
|
## [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local RayIntersectionInfoValue = collision_find_surface_on_ray(startX, startY, startZ, endX, endY, endZ)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| startX | `number` |
|
||||||
|
| startY | `number` |
|
||||||
|
| startZ | `number` |
|
||||||
|
| endX | `number` |
|
||||||
|
| endY | `number` |
|
||||||
|
| endZ | `number` |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
[RayIntersectionInfo](structs.md#RayIntersectionInfo)
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 endX, f32 endY, f32 endZ);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
# functions from smlua_obj_utils.h
|
# functions from smlua_obj_utils.h
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
- [ParallelTrackingPoint](#ParallelTrackingPoint)
|
- [ParallelTrackingPoint](#ParallelTrackingPoint)
|
||||||
- [PlayerCameraState](#PlayerCameraState)
|
- [PlayerCameraState](#PlayerCameraState)
|
||||||
- [PlayerGeometry](#PlayerGeometry)
|
- [PlayerGeometry](#PlayerGeometry)
|
||||||
|
- [RayIntersectionInfo](#RayIntersectionInfo)
|
||||||
- [SPTask](#SPTask)
|
- [SPTask](#SPTask)
|
||||||
- [SoundState](#SoundState)
|
- [SoundState](#SoundState)
|
||||||
- [SpawnInfo](#SpawnInfo)
|
- [SpawnInfo](#SpawnInfo)
|
||||||
|
|
@ -1604,6 +1605,17 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [RayIntersectionInfo](#RayIntersectionInfo)
|
||||||
|
|
||||||
|
| Field | Type | Access |
|
||||||
|
| ----- | ---- | ------ |
|
||||||
|
| hitPos | [Vec3f](structs.md#Vec3f) | read-only |
|
||||||
|
| surface | [Surface](structs.md#Surface) | |
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [SoundState](#SoundState)
|
## [SoundState](#SoundState)
|
||||||
|
|
||||||
| Field | Type | Access |
|
| Field | Type | Access |
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "src/game/object_helpers.h"
|
#include "src/game/object_helpers.h"
|
||||||
#include "src/game/mario_step.h"
|
#include "src/game/mario_step.h"
|
||||||
#include "src/pc/lua/smlua_anim_utils.h"
|
#include "src/pc/lua/smlua_anim_utils.h"
|
||||||
|
#include "src/pc/lua/smlua_misc_utils.h"
|
||||||
#include "src/game/spawn_sound.h"
|
#include "src/game/spawn_sound.h"
|
||||||
|
|
||||||
#include "include/object_fields.h"
|
#include "include/object_fields.h"
|
||||||
|
|
@ -1404,6 +1405,12 @@ static struct LuaObjectField sPlayerGeometryFields[LUA_PLAYER_GEOMETRY_FIELD_COU
|
||||||
{ "waterHeight", LVT_F32, offsetof(struct PlayerGeometry, waterHeight), false, LOT_NONE },
|
{ "waterHeight", LVT_F32, offsetof(struct PlayerGeometry, waterHeight), false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define LUA_RAY_INTERSECTION_INFO_FIELD_COUNT 2
|
||||||
|
static struct LuaObjectField sRayIntersectionInfoFields[LUA_RAY_INTERSECTION_INFO_FIELD_COUNT] = {
|
||||||
|
{ "hitPos", LVT_COBJECT, offsetof(struct RayIntersectionInfo, hitPos), true, LOT_VEC3F },
|
||||||
|
{ "surface", LVT_COBJECT_P, offsetof(struct RayIntersectionInfo, surface), false, LOT_SURFACE },
|
||||||
|
};
|
||||||
|
|
||||||
#define LUA_SOUND_STATE_FIELD_COUNT 4
|
#define LUA_SOUND_STATE_FIELD_COUNT 4
|
||||||
static struct LuaObjectField sSoundStateFields[LUA_SOUND_STATE_FIELD_COUNT] = {
|
static struct LuaObjectField sSoundStateFields[LUA_SOUND_STATE_FIELD_COUNT] = {
|
||||||
{ "animFrame1", LVT_S8, offsetof(struct SoundState, animFrame1), false, LOT_NONE },
|
{ "animFrame1", LVT_S8, offsetof(struct SoundState, animFrame1), false, LOT_NONE },
|
||||||
|
|
@ -1599,6 +1606,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
||||||
{ LOT_PARALLELTRACKINGPOINT, sParallelTrackingPointFields, LUA_PARALLEL_TRACKING_POINT_FIELD_COUNT },
|
{ LOT_PARALLELTRACKINGPOINT, sParallelTrackingPointFields, LUA_PARALLEL_TRACKING_POINT_FIELD_COUNT },
|
||||||
{ LOT_PLAYERCAMERASTATE, sPlayerCameraStateFields, LUA_PLAYER_CAMERA_STATE_FIELD_COUNT },
|
{ LOT_PLAYERCAMERASTATE, sPlayerCameraStateFields, LUA_PLAYER_CAMERA_STATE_FIELD_COUNT },
|
||||||
{ LOT_PLAYERGEOMETRY, sPlayerGeometryFields, LUA_PLAYER_GEOMETRY_FIELD_COUNT },
|
{ LOT_PLAYERGEOMETRY, sPlayerGeometryFields, LUA_PLAYER_GEOMETRY_FIELD_COUNT },
|
||||||
|
{ LOT_RAYINTERSECTIONINFO, sRayIntersectionInfoFields, LUA_RAY_INTERSECTION_INFO_FIELD_COUNT },
|
||||||
{ LOT_SOUNDSTATE, sSoundStateFields, LUA_SOUND_STATE_FIELD_COUNT },
|
{ LOT_SOUNDSTATE, sSoundStateFields, LUA_SOUND_STATE_FIELD_COUNT },
|
||||||
{ LOT_SPAWNINFO, sSpawnInfoFields, LUA_SPAWN_INFO_FIELD_COUNT },
|
{ LOT_SPAWNINFO, sSpawnInfoFields, LUA_SPAWN_INFO_FIELD_COUNT },
|
||||||
{ LOT_SPAWNPARTICLESINFO, sSpawnParticlesInfoFields, LUA_SPAWN_PARTICLES_INFO_FIELD_COUNT },
|
{ LOT_SPAWNPARTICLESINFO, sSpawnParticlesInfoFields, LUA_SPAWN_PARTICLES_INFO_FIELD_COUNT },
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ enum LuaObjectAutogenType {
|
||||||
LOT_PARALLELTRACKINGPOINT,
|
LOT_PARALLELTRACKINGPOINT,
|
||||||
LOT_PLAYERCAMERASTATE,
|
LOT_PLAYERCAMERASTATE,
|
||||||
LOT_PLAYERGEOMETRY,
|
LOT_PLAYERGEOMETRY,
|
||||||
|
LOT_RAYINTERSECTIONINFO,
|
||||||
LOT_SOUNDSTATE,
|
LOT_SOUNDSTATE,
|
||||||
LOT_SPAWNINFO,
|
LOT_SPAWNINFO,
|
||||||
LOT_SPAWNPARTICLESINFO,
|
LOT_SPAWNPARTICLESINFO,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include "src/pc/network/network_player.h"
|
#include "src/pc/network/network_player.h"
|
||||||
#include "include/behavior_table.h"
|
#include "include/behavior_table.h"
|
||||||
#include "src/pc/lua/smlua_obj_utils.h"
|
#include "src/pc/lua/smlua_obj_utils.h"
|
||||||
|
#include "src/pc/lua/smlua_misc_utils.h"
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
//////////////////////
|
||||||
|
|
@ -7263,6 +7264,31 @@ int smlua_func_save_file_get_total_star_count(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// smlua_misc_utils.h //
|
||||||
|
////////////////////////
|
||||||
|
|
||||||
|
int smlua_func_collision_find_surface_on_ray(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
|
||||||
|
|
||||||
|
f32 startX = smlua_to_number(L, 1);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
f32 startY = smlua_to_number(L, 2);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
f32 startZ = smlua_to_number(L, 3);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
f32 endX = smlua_to_number(L, 4);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
f32 endY = smlua_to_number(L, 5);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
f32 endZ = smlua_to_number(L, 6);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
|
||||||
|
smlua_push_object(L, LOT_RAYINTERSECTIONINFO, collision_find_surface_on_ray(startX, startY, startZ, endX, endY, endZ));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// smlua_obj_utils.h //
|
// smlua_obj_utils.h //
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
@ -8455,6 +8481,9 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "save_file_get_star_flags", smlua_func_save_file_get_star_flags);
|
smlua_bind_function(L, "save_file_get_star_flags", smlua_func_save_file_get_star_flags);
|
||||||
smlua_bind_function(L, "save_file_get_total_star_count", smlua_func_save_file_get_total_star_count);
|
smlua_bind_function(L, "save_file_get_total_star_count", smlua_func_save_file_get_total_star_count);
|
||||||
|
|
||||||
|
// smlua_misc_utils.h
|
||||||
|
smlua_bind_function(L, "collision_find_surface_on_ray", smlua_func_collision_find_surface_on_ray);
|
||||||
|
|
||||||
// smlua_obj_utils.h
|
// smlua_obj_utils.h
|
||||||
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
||||||
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
|
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
|
||||||
|
|
|
||||||
14
src/pc/lua/smlua_misc_utils.c
Normal file
14
src/pc/lua/smlua_misc_utils.c
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "smlua.h"
|
||||||
|
#include "smlua_misc_utils.h"
|
||||||
|
#include "src/engine/surface_collision.h"
|
||||||
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
|
struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 endX, f32 endY, f32 endZ) {
|
||||||
|
static struct RayIntersectionInfo info = { 0 };
|
||||||
|
Vec3f orig = { startX, startY, startZ };
|
||||||
|
Vec3f end = { endX, endY, endZ };
|
||||||
|
find_surface_on_ray(orig, end, &info.surface, info.hitPos);
|
||||||
|
return &info;
|
||||||
|
}
|
||||||
11
src/pc/lua/smlua_misc_utils.h
Normal file
11
src/pc/lua/smlua_misc_utils.h
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef SMLUA_MISC_UTILS_H
|
||||||
|
#define SMLUA_MISC_UTILS_H
|
||||||
|
|
||||||
|
struct RayIntersectionInfo {
|
||||||
|
struct Surface* surface;
|
||||||
|
Vec3f hitPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 endX, f32 endY, f32 endZ);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Reference in a new issue