PhysX work
This commit is contained in:
@@ -79,10 +79,8 @@ Entity :: struct {
|
||||
animator: Animator; @DontSerialize
|
||||
|
||||
// Physics
|
||||
body : Physics_Body;
|
||||
collider : Collider;
|
||||
physx_static: *PhysX.PxRigidStatic;
|
||||
physx_dynamic: *PhysX.PxRigidDynamic;
|
||||
physx_handle: PhysX_Handle;
|
||||
velocity: Vector3;
|
||||
|
||||
// End physics
|
||||
|
||||
@@ -208,10 +206,6 @@ entity_should_be_rendered :: (e: *Entity) -> bool {
|
||||
destroy_entity :: (e: *Entity) {
|
||||
call_correct_deinit_entity(e);
|
||||
|
||||
if e.collider.mesh.vertices.data != null {
|
||||
array_free(e.collider.mesh.vertices);
|
||||
}
|
||||
|
||||
for 0..e.renderable.num_nodes-1 {
|
||||
node_data := e.renderable.nodes[it];
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ Mesh_Entity :: struct {
|
||||
}
|
||||
|
||||
init_entity :: (e: *Mesh_Entity) {
|
||||
log_error("Missing collision on Mesh Entities\n");
|
||||
assert(false);
|
||||
if e.model_path.count > 0 {
|
||||
load_model_into_entity(e, get_or_load_model(e.model_path));
|
||||
e.flags |= .COLLISION | .STATIC;
|
||||
e.collider.type = .MESH;
|
||||
e.collider.bake_mode = .FULL_MESH;
|
||||
//e.flags |= .COLLISION | .STATIC;
|
||||
//e.collider.type = .MESH;
|
||||
//e.collider.bake_mode = .FULL_MESH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Scene :: struct {
|
||||
|
||||
mode: Engine_Mode;
|
||||
|
||||
physx_scene: *PhysX.PxScene;
|
||||
physx_scene: PhysX_Scene;
|
||||
|
||||
using custom_fields: _Custom_Scene_Fields;
|
||||
}
|
||||
@@ -76,8 +76,6 @@ load_scene :: (name: string, make_current: bool = true) -> *Scene {
|
||||
next_entity_id = cast(Entity_Id)(highest + 1);
|
||||
|
||||
update_transforms(scene);
|
||||
calculate_aabbs(scene);
|
||||
make_sure_nothing_collides(scene);
|
||||
|
||||
if engine.procs.on_scene_loaded != null {
|
||||
engine.procs.on_scene_loaded(scene, engine.mode);
|
||||
@@ -144,7 +142,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 +193,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}));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user