Character controller
This commit is contained in:
@@ -6,6 +6,7 @@ PhysX_Handle :: #type, distinct u32;
|
|||||||
PhysX_Actor_Type :: enum {
|
PhysX_Actor_Type :: enum {
|
||||||
STATIC;
|
STATIC;
|
||||||
DYNAMIC;
|
DYNAMIC;
|
||||||
|
CHARACTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysX_Actor :: struct {
|
PhysX_Actor :: struct {
|
||||||
@@ -16,12 +17,15 @@ PhysX_Actor :: struct {
|
|||||||
union {
|
union {
|
||||||
static: *PhysX.PxRigidStatic;
|
static: *PhysX.PxRigidStatic;
|
||||||
dynamic: *PhysX.PxRigidDynamic;
|
dynamic: *PhysX.PxRigidDynamic;
|
||||||
|
controller: *PhysX.PxController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysX_Scene :: struct {
|
PhysX_Scene :: struct {
|
||||||
scene: *PhysX.PxScene;
|
scene: *PhysX.PxScene;
|
||||||
actors : PArray(PhysX_Actor, PhysX_Handle);
|
actors : PArray(PhysX_Actor, PhysX_Handle);
|
||||||
|
|
||||||
|
controller_manager: *PhysX.PxControllerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_physx :: () {
|
init_physx :: () {
|
||||||
@@ -77,7 +81,25 @@ on_physx_trigger :: (_u: *void, pair: *PhysX.PxTriggerPair, count: u32) #c_call
|
|||||||
}
|
}
|
||||||
|
|
||||||
tick_physx :: (scene: *PhysX_Scene, dt: float) {
|
tick_physx :: (scene: *PhysX_Scene, dt: float) {
|
||||||
|
// Move all character controllers first
|
||||||
|
filter_data := PhysX.PxFilterData_new();
|
||||||
|
filter := PhysX.PxControllerFilters_new();
|
||||||
|
for e: engine.current_scene.entities {
|
||||||
|
if e.flags & .PHYSICS {
|
||||||
|
if e.physics.physx_handle != 0 {
|
||||||
|
physx_actor := parray_get(*engine.current_scene.physx_scene.actors, e.physics.physx_handle);
|
||||||
|
if physx_actor.type == .CHARACTER {
|
||||||
|
movement := e.physics.velocity * dt;
|
||||||
|
flags := PhysX.PxController_move(physx_actor.controller, *movement, 0.001, dt, *filter, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulate
|
||||||
PhysX.PxScene_simulate(scene.scene, dt, null, null, 0, true);
|
PhysX.PxScene_simulate(scene.scene, dt, null, null, 0, true);
|
||||||
|
|
||||||
|
// Sync results back
|
||||||
PhysX.PxScene_fetchResults(scene.scene, true, null);
|
PhysX.PxScene_fetchResults(scene.scene, true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +142,7 @@ init_physx_scene :: (game_scene: *Scene) {
|
|||||||
physx_scene.scene = scene;
|
physx_scene.scene = scene;
|
||||||
physx_scene.actors.data.allocator = game_scene.allocator;
|
physx_scene.actors.data.allocator = game_scene.allocator;
|
||||||
physx_scene.actors.indices.allocator = game_scene.allocator;
|
physx_scene.actors.indices.allocator = game_scene.allocator;
|
||||||
|
physx_scene.controller_manager = PhysX.PxCreateControllerManager(scene, false);
|
||||||
|
|
||||||
game_scene.physx_scene = physx_scene;
|
game_scene.physx_scene = physx_scene;
|
||||||
}
|
}
|
||||||
@@ -134,8 +157,10 @@ pre_physx_sync :: (game_scene: *Scene) {
|
|||||||
if it.physics.physx_handle != 0 {
|
if it.physics.physx_handle != 0 {
|
||||||
// @Incomplete: Update the transform!
|
// @Incomplete: Update the transform!
|
||||||
physx_actor := parray_get(*game_scene.physx_scene.actors, it.physics.physx_handle);
|
physx_actor := parray_get(*game_scene.physx_scene.actors, it.physics.physx_handle);
|
||||||
if physx_actor.type == .DYNAMIC {
|
if physx_actor.type == {
|
||||||
PhysX.PxRigidDynamic_setLinearVelocity(physx_actor.dynamic, *it.physics.velocity, true);
|
case .DYNAMIC; {
|
||||||
|
PhysX.PxRigidDynamic_setLinearVelocity(physx_actor.dynamic, *it.physics.velocity, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
create_physx_actor(it);
|
create_physx_actor(it);
|
||||||
@@ -167,194 +192,222 @@ post_physx_sync :: (game_scene: *Scene) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_physx_actor :: (e: *Entity) {
|
create_physx_actor :: (e: *Entity) {
|
||||||
actor : *PhysX.PxRigidActor;
|
if e.physics.type == .CHARACTER {
|
||||||
transform : PhysX.PxTransform;
|
material := PhysX.PxPhysics_createMaterial(physics, e.physics.static_friction, e.physics.dynamic_friction, e.physics.restitution);
|
||||||
position := e.transform.position + e.physics.offset;
|
|
||||||
|
|
||||||
if e.physics.type == .CAPSULE {
|
desc := PhysX.PxCapsuleControllerDesc_new_alloc();
|
||||||
angle := PI * 0.5;
|
desc.height = e.physics.character.height;
|
||||||
half_angle := angle * 0.5;
|
desc.radius = e.physics.character.radius;
|
||||||
|
desc.stepOffset = 0.2;
|
||||||
|
desc.slopeLimit = cos(PI * 0.25);
|
||||||
|
desc.contactOffset = 0.1;
|
||||||
|
desc.material = material;
|
||||||
|
desc.position = .{};
|
||||||
|
desc.density = 10.0;
|
||||||
|
desc.userData = null;
|
||||||
|
|
||||||
sin_half := sin(half_angle);
|
scene := engine.current_scene.physx_scene;
|
||||||
cos_half := cos(half_angle);
|
controller := PhysX.PxControllerManager_createController(scene.controller_manager, desc);
|
||||||
|
PhysX.PxCapsuleControllerDesc_delete(desc);
|
||||||
|
|
||||||
rotation := Quaternion.{0, 0, sin(-PI * 0.25), cos(-PI * 0.25)};
|
physics_actor : PhysX_Actor;
|
||||||
transform = PhysX.PxTransform_new(*position, *rotation);
|
physics_actor.type = .CHARACTER;
|
||||||
|
physics_actor.sync_rotation_from_physx = false;//e.physics.type != .CAPSULE; // @Incomplete
|
||||||
|
|
||||||
|
physics_actor.controller = controller;
|
||||||
|
|
||||||
|
e.physics.physx_handle = parray_add(*e.scene.physx_scene.actors, physics_actor);
|
||||||
|
e.physics.enabled = true;
|
||||||
} else {
|
} else {
|
||||||
transform = PhysX.PxTransform_new(*position, *e.transform.orientation);
|
actor : *PhysX.PxRigidActor;
|
||||||
}
|
transform : PhysX.PxTransform;
|
||||||
|
position := e.transform.position + e.physics.offset;
|
||||||
|
|
||||||
if e.physics.dynamic {
|
if e.physics.type == .CAPSULE {
|
||||||
dynamic := PhysX.PxPhysics_createRigidDynamic(physics, *transform);
|
angle := PI * 0.5;
|
||||||
actor = dynamic;
|
half_angle := angle * 0.5;
|
||||||
|
|
||||||
if e.physics.lock & .ANGULAR_X {
|
sin_half := sin(half_angle);
|
||||||
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularX, true);
|
cos_half := cos(half_angle);
|
||||||
|
|
||||||
|
rotation := Quaternion.{0, 0, sin(-PI * 0.25), cos(-PI * 0.25)};
|
||||||
|
transform = PhysX.PxTransform_new(*position, *rotation);
|
||||||
|
} else {
|
||||||
|
transform = PhysX.PxTransform_new(*position, *e.transform.orientation);
|
||||||
}
|
}
|
||||||
if e.physics.lock & .ANGULAR_Y {
|
|
||||||
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularY, true);
|
if e.physics.dynamic {
|
||||||
|
dynamic := PhysX.PxPhysics_createRigidDynamic(physics, *transform);
|
||||||
|
actor = dynamic;
|
||||||
|
|
||||||
|
if e.physics.lock & .ANGULAR_X {
|
||||||
|
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularX, true);
|
||||||
|
}
|
||||||
|
if e.physics.lock & .ANGULAR_Y {
|
||||||
|
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularY, true);
|
||||||
|
}
|
||||||
|
if e.physics.lock & .ANGULAR_Z {
|
||||||
|
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularZ, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
actor = PhysX.PxPhysics_createRigidStatic(physics, *transform);
|
||||||
}
|
}
|
||||||
if e.physics.lock & .ANGULAR_Z {
|
|
||||||
PhysX.PxRigidDynamic_setRigidDynamicLockFlag(dynamic, xx PhysX.PxRigidDynamicLockFlags.LockAngularZ, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
actor = PhysX.PxPhysics_createRigidStatic(physics, *transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
material := PhysX.PxPhysics_createMaterial(physics, e.physics.static_friction, e.physics.dynamic_friction, e.physics.restitution);
|
material := PhysX.PxPhysics_createMaterial(physics, e.physics.static_friction, e.physics.dynamic_friction, e.physics.restitution);
|
||||||
geo : *PhysX.PxGeometry;
|
geo : *PhysX.PxGeometry;
|
||||||
|
|
||||||
actor.userData = e;
|
actor.userData = e;
|
||||||
|
|
||||||
if e.physics.type == {
|
if e.physics.type == {
|
||||||
case .SPHERE; {
|
case .SPHERE; {
|
||||||
geo = PhysX.PxSphereGeometry_new(e.physics.sphere.radius);
|
geo = PhysX.PxSphereGeometry_new(e.physics.sphere.radius);
|
||||||
}
|
}
|
||||||
case .BOX; {
|
case .BOX; {
|
||||||
geo = PhysX.PxBoxGeometry_new(e.physics.box.half_extent*e.transform.scale);
|
geo = PhysX.PxBoxGeometry_new(e.physics.box.half_extent*e.transform.scale);
|
||||||
}
|
}
|
||||||
case .CAPSULE; {
|
case .CAPSULE; {
|
||||||
geo = PhysX.PxCapsuleGeometry_new(e.physics.capsule.radius, e.physics.capsule.half_height-e.physics.capsule.radius);
|
geo = PhysX.PxCapsuleGeometry_new(e.physics.capsule.radius, e.physics.capsule.half_height-e.physics.capsule.radius);
|
||||||
}
|
}
|
||||||
case .CONVEX_MESH; {
|
case .CONVEX_MESH; {
|
||||||
if e.flags & .RENDERABLE {
|
if e.flags & .RENDERABLE {
|
||||||
points : [..] Vector3;
|
points : [..] Vector3;
|
||||||
points.allocator = temp;
|
points.allocator = temp;
|
||||||
indices : [..] u32;
|
indices : [..] u32;
|
||||||
indices.allocator = temp;
|
indices.allocator = temp;
|
||||||
|
|
||||||
model := get_model_by_handle(e.renderable.model);
|
model := get_model_by_handle(e.renderable.model);
|
||||||
|
|
||||||
for node, node_index: model.nodes {
|
for node, node_index: model.nodes {
|
||||||
render_data := e.renderable.nodes[node_index];
|
render_data := e.renderable.nodes[node_index];
|
||||||
|
|
||||||
success, inv_matrix := inverse(e.transform.model_matrix);
|
success, inv_matrix := inverse(e.transform.model_matrix);
|
||||||
// We need to undo the local to world part of every world matrix
|
// We need to undo the local to world part of every world matrix
|
||||||
matrix := inv_matrix * render_data.transform.world_matrix;
|
matrix := inv_matrix * render_data.transform.world_matrix;
|
||||||
|
|
||||||
if node.meshes.count > 0 {
|
if node.meshes.count > 0 {
|
||||||
for m, mi: node.meshes {
|
for m, mi: node.meshes {
|
||||||
index_start : u32 = xx indices.count;
|
index_start : u32 = xx indices.count;
|
||||||
mesh := parray_get(*engine.renderer.meshes, m);
|
mesh := parray_get(*engine.renderer.meshes, m);
|
||||||
for v: mesh.positions {
|
for v: mesh.positions {
|
||||||
array_add(*points, v);//transform_position(v, matrix));
|
array_add(*points, v);//transform_position(v, matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
for i: mesh.indices {
|
for i: mesh.indices {
|
||||||
array_add(*indices, index_start + i);
|
array_add(*indices, index_start + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mesh_desc := PhysX.PxConvexMeshDesc_new();
|
||||||
|
mesh_desc.points.count = xx points.count;
|
||||||
|
mesh_desc.points.stride = size_of(Vector3);
|
||||||
|
mesh_desc.points.data = points.data;
|
||||||
|
|
||||||
|
mesh_desc.polygons.count = cast(u32)(indices.count / 3);
|
||||||
|
mesh_desc.polygons.stride = 3 * size_of(u32);
|
||||||
|
mesh_desc.polygons.data = indices.data;
|
||||||
|
|
||||||
|
if !PhysX.PxValidateConvexMesh(*cooking_params, *mesh_desc) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream : PhysX.PxOutputStream;
|
||||||
|
callback := PhysX.PxGetStandaloneInsertionCallback();
|
||||||
|
//read_buffer : PhysX.PxDefaultMemoryInputData_new(;
|
||||||
|
cond : s32;
|
||||||
|
mesh := PhysX.PxCreateConvexMesh(*cooking_params, *mesh_desc, callback, null);
|
||||||
|
scale := PhysX.PxMeshScale_new(*e.transform.scale);
|
||||||
|
geo = PhysX.PxConvexMeshGeometry_new(mesh, *scale, 0);
|
||||||
}
|
}
|
||||||
mesh_desc := PhysX.PxConvexMeshDesc_new();
|
|
||||||
mesh_desc.points.count = xx points.count;
|
|
||||||
mesh_desc.points.stride = size_of(Vector3);
|
|
||||||
mesh_desc.points.data = points.data;
|
|
||||||
|
|
||||||
mesh_desc.polygons.count = cast(u32)(indices.count / 3);
|
|
||||||
mesh_desc.polygons.stride = 3 * size_of(u32);
|
|
||||||
mesh_desc.polygons.data = indices.data;
|
|
||||||
|
|
||||||
if !PhysX.PxValidateConvexMesh(*cooking_params, *mesh_desc) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
stream : PhysX.PxOutputStream;
|
|
||||||
callback := PhysX.PxGetStandaloneInsertionCallback();
|
|
||||||
//read_buffer : PhysX.PxDefaultMemoryInputData_new(;
|
|
||||||
cond : s32;
|
|
||||||
mesh := PhysX.PxCreateConvexMesh(*cooking_params, *mesh_desc, callback, null);
|
|
||||||
scale := PhysX.PxMeshScale_new(*e.transform.scale);
|
|
||||||
geo = PhysX.PxConvexMeshGeometry_new(mesh, *scale, 0);
|
|
||||||
}
|
}
|
||||||
}
|
case .TRIANGLE_MESH; {
|
||||||
case .TRIANGLE_MESH; {
|
if e.flags & .RENDERABLE {
|
||||||
if e.flags & .RENDERABLE {
|
points : [..] Vector3;
|
||||||
points : [..] Vector3;
|
points.allocator = temp;
|
||||||
points.allocator = temp;
|
indices : [..] u32;
|
||||||
indices : [..] u32;
|
indices.allocator = temp;
|
||||||
indices.allocator = temp;
|
|
||||||
|
|
||||||
model := get_model_by_handle(e.renderable.model);
|
model := get_model_by_handle(e.renderable.model);
|
||||||
|
|
||||||
for node, node_index: model.nodes {
|
for node, node_index: model.nodes {
|
||||||
render_data := e.renderable.nodes[node_index];
|
render_data := e.renderable.nodes[node_index];
|
||||||
|
|
||||||
success, inv_matrix := inverse(e.transform.model_matrix);
|
success, inv_matrix := inverse(e.transform.model_matrix);
|
||||||
// We need to undo the local to world part of every world matrix
|
// We need to undo the local to world part of every world matrix
|
||||||
matrix := inv_matrix * render_data.transform.world_matrix;
|
matrix := inv_matrix * render_data.transform.world_matrix;
|
||||||
|
|
||||||
if node.meshes.count > 0 {
|
if node.meshes.count > 0 {
|
||||||
print("NUM MESHES %\n", node.meshes.count);
|
print("NUM MESHES %\n", node.meshes.count);
|
||||||
for m, mi: node.meshes {
|
for m, mi: node.meshes {
|
||||||
index_start : u32 = xx indices.count;
|
index_start : u32 = xx indices.count;
|
||||||
mesh := parray_get(*engine.renderer.meshes, m);
|
mesh := parray_get(*engine.renderer.meshes, m);
|
||||||
for v: mesh.positions {
|
for v: mesh.positions {
|
||||||
array_add(*points, v);//transform_position(v, matrix));
|
array_add(*points, v);//transform_position(v, matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
for i: mesh.indices {
|
for i: mesh.indices {
|
||||||
array_add(*indices, index_start + i);
|
array_add(*indices, index_start + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mesh_desc : PhysX.PxTriangleMeshDesc;
|
||||||
|
mesh_desc.points.count = xx points.count;
|
||||||
|
mesh_desc.points.stride = size_of(Vector3);
|
||||||
|
mesh_desc.points.data = points.data;
|
||||||
|
|
||||||
|
mesh_desc.triangles.count = cast(u32)(indices.count / 3);
|
||||||
|
mesh_desc.triangles.stride = 3 * size_of(u32);
|
||||||
|
mesh_desc.triangles.data = indices.data;
|
||||||
|
|
||||||
|
//if !PhysX.PxValidateTriangleMesh(*cooking_params, *mesh_desc) {
|
||||||
|
// assert(false);
|
||||||
|
//}
|
||||||
|
|
||||||
|
callback := PhysX.PxGetStandaloneInsertionCallback();
|
||||||
|
mesh := PhysX.PxCreateTriangleMesh(*cooking_params, *mesh_desc, callback, null);
|
||||||
|
scale := PhysX.PxMeshScale_new(*e.transform.scale);
|
||||||
|
geo = PhysX.PxTriangleMeshGeometry_new(mesh, *scale, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mesh_desc : PhysX.PxTriangleMeshDesc;
|
|
||||||
mesh_desc.points.count = xx points.count;
|
|
||||||
mesh_desc.points.stride = size_of(Vector3);
|
|
||||||
mesh_desc.points.data = points.data;
|
|
||||||
|
|
||||||
mesh_desc.triangles.count = cast(u32)(indices.count / 3);
|
|
||||||
mesh_desc.triangles.stride = 3 * size_of(u32);
|
|
||||||
mesh_desc.triangles.data = indices.data;
|
|
||||||
|
|
||||||
//if !PhysX.PxValidateTriangleMesh(*cooking_params, *mesh_desc) {
|
|
||||||
// assert(false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
callback := PhysX.PxGetStandaloneInsertionCallback();
|
|
||||||
mesh := PhysX.PxCreateTriangleMesh(*cooking_params, *mesh_desc, callback, null);
|
|
||||||
scale := PhysX.PxMeshScale_new(*e.transform.scale);
|
|
||||||
geo = PhysX.PxTriangleMeshGeometry_new(mesh, *scale, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shape := PhysX.PxPhysics_createShape(physics, geo, material, false, ifx e.physics.trigger then PHYSX_DEFAULT_TRIGGER_SHAPE_FLAGS else PHYSX_DEFAULT_SIMULATION_SHAPE_FLAGS);
|
||||||
|
|
||||||
|
// Setup layers
|
||||||
|
filter_data := PhysX.PxFilterData_new();
|
||||||
|
filter_data.word0 = 1;
|
||||||
|
filter_data.word1 = 1;
|
||||||
|
filter_data.word2 = 1;
|
||||||
|
filter_data.word3 = 1;
|
||||||
|
|
||||||
|
//PhysX.PxShape_setSimulationFilterData(shape, *filter_data);
|
||||||
|
//PhysX.PxShape_setQueryFilterData(shape, *filter_data);
|
||||||
|
|
||||||
|
PhysX.PxRigidActor_attachShape(actor, shape);
|
||||||
|
|
||||||
|
if e.physics.dynamic {
|
||||||
|
PhysX.PxRigidBodyExt_updateMassAndInertia(cast(*PhysX.PxRigidBody)actor, 1000.0, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
PhysX.PxScene_addActor(e.scene.physx_scene.scene, actor, null);
|
||||||
|
|
||||||
|
PhysX.PxShape_release(shape);
|
||||||
|
PhysX.PxBase_release(material);
|
||||||
|
|
||||||
|
physics_actor : PhysX_Actor;
|
||||||
|
physics_actor.type = ifx e.physics.dynamic then .DYNAMIC else .STATIC;
|
||||||
|
physics_actor.sync_rotation_from_physx = e.physics.type != .CAPSULE; // @Incomplete
|
||||||
|
|
||||||
|
if physics_actor.type == .DYNAMIC {
|
||||||
|
physics_actor.dynamic = xx actor;
|
||||||
|
} else {
|
||||||
|
physics_actor.static = xx actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.physics.physx_handle = parray_add(*e.scene.physx_scene.actors, physics_actor);
|
||||||
|
e.physics.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shape := PhysX.PxPhysics_createShape(physics, geo, material, false, ifx e.physics.trigger then PHYSX_DEFAULT_TRIGGER_SHAPE_FLAGS else PHYSX_DEFAULT_SIMULATION_SHAPE_FLAGS);
|
|
||||||
|
|
||||||
// Setup layers
|
|
||||||
filter_data := PhysX.PxFilterData_new();
|
|
||||||
filter_data.word0 = 1;
|
|
||||||
filter_data.word1 = 1;
|
|
||||||
filter_data.word2 = 1;
|
|
||||||
filter_data.word3 = 1;
|
|
||||||
|
|
||||||
//PhysX.PxShape_setSimulationFilterData(shape, *filter_data);
|
|
||||||
//PhysX.PxShape_setQueryFilterData(shape, *filter_data);
|
|
||||||
|
|
||||||
PhysX.PxRigidActor_attachShape(actor, shape);
|
|
||||||
|
|
||||||
if e.physics.dynamic {
|
|
||||||
PhysX.PxRigidBodyExt_updateMassAndInertia(cast(*PhysX.PxRigidBody)actor, 1000.0, null, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysX.PxScene_addActor(e.scene.physx_scene.scene, actor, null);
|
|
||||||
|
|
||||||
PhysX.PxShape_release(shape);
|
|
||||||
PhysX.PxBase_release(material);
|
|
||||||
|
|
||||||
physics_actor : PhysX_Actor;
|
|
||||||
physics_actor.type = ifx e.physics.dynamic then .DYNAMIC else .STATIC;
|
|
||||||
physics_actor.sync_rotation_from_physx = e.physics.type != .CAPSULE; // @Incomplete
|
|
||||||
|
|
||||||
if physics_actor.type == .DYNAMIC {
|
|
||||||
physics_actor.dynamic = xx actor;
|
|
||||||
} else {
|
|
||||||
physics_actor.static = xx actor;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.physics.physx_handle = parray_add(*e.scene.physx_scene.actors, physics_actor);
|
|
||||||
e.physics.enabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Hit :: struct {
|
Hit :: struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user