PhysX work

This commit is contained in:
2025-07-11 01:39:46 +02:00
parent 7e354b0417
commit 5f61c04912
5 changed files with 129 additions and 41 deletions

View File

@@ -81,8 +81,9 @@ Entity :: struct {
// Physics
body : Physics_Body;
collider : Collider;
physx_static: *PhysX.PxRigidStatic;
physx_dynamic: *PhysX.PxRigidDynamic;
physx_handle: PhysX_Handle;
velocity: Vector3;
// End physics

View File

@@ -22,7 +22,7 @@ Scene :: struct {
mode: Engine_Mode;
physx_scene: *PhysX.PxScene;
physx_scene: PhysX_Scene;
using custom_fields: _Custom_Scene_Fields;
}
@@ -144,7 +144,7 @@ unload_scene :: (scene: *Scene) {
destroy_entity(e);
}
PhysX.PxScene_release(scene.physx_scene);
deinit_physx_scene(scene);
free(scene.name);
fini(*scene.pool);
@@ -195,7 +195,7 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene {
array_reserve(*scene.entities, max_entities);
scene.physx_scene = create_physx_scene();
init_physx_scene(scene);
scene.directional_light.color_and_intensity = .{1,1,1,2};
scene.directional_light.direction = to_v4(normalize(Vector3.{0.4, -0.7, 0.4}));

View File

@@ -170,6 +170,16 @@ set_scale :: (transform: *Transform, scale: float, calculate_matrix: bool = true
if calculate_matrix update_matrix(transform);
}
set_position_rotation :: (transform: *Transform, position: Vector3, rotation: Quaternion, calculate_matrix: bool = true) {
transform.position = position;
transform.orientation = rotation;
if calculate_matrix update_matrix(transform);
}
set_position_rotation :: (e: *Entity, position: Vector3, rotation: Quaternion, calculate_matrix: bool = true) {
set_position_rotation(*e.transform, position, rotation, calculate_matrix);
}
set_position_rotation_scale :: (transform: *Transform, position: Vector3, rotation: Quaternion, scale: Vector3, calculate_matrix: bool = true) {
transform.position = position;
transform.orientation = rotation;