Collision shapes will only be added to broadphase if the collider is active

This commit is contained in:
Diren D Bharwani 2023-03-04 13:30:29 +08:00
parent 6200e3f533
commit e2d96569b5
6 changed files with 55 additions and 29973 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Camera Component: Camera Component:
Position: {x: 1, y: 5, z: 5} Position: {x: 0, y: 2, z: 5}
Pitch: 0 Pitch: 0
Yaw: 0 Yaw: 0
Roll: 0 Roll: 0
@ -28,9 +28,9 @@
Collider Component: Collider Component:
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 6 Collision Tag: 0
Type: Sphere Type: Box
Radius: 1 Half Extents: {x: 1, y: 1, z: 1}
Friction: 0.400000006 Friction: 0.400000006
Bounciness: 0 Bounciness: 0
Density: 1 Density: 1
@ -41,17 +41,17 @@
- EID: 3 - EID: 3
Name: Default Name: Default
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 1
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 5, z: 0} Translate: {x: -0.597273231, y: 5, z: 0}
Rotate: {x: -0, y: 0.785398006, z: -0} Rotate: {x: -0, y: 0, z: 0.490080804}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 0.999999702, y: 0.999999702, z: 1}
IsActive: true IsActive: true
RigidBody Component: RigidBody Component:
Type: Dynamic Type: Static
Auto Mass: false Auto Mass: false
Mass: 1 Mass: .inf
Drag: 0.00999999978 Drag: 0.00999999978
Angular Drag: 0.00999999978 Angular Drag: 0.00999999978
Use Gravity: true Use Gravity: true
@ -81,4 +81,44 @@
- Type: PhysicsTestObj - Type: PhysicsTestObj
Enabled: true Enabled: true
forceAmount: 50 forceAmount: 50
torqueAmount: 25 torqueAmount: 25
- EID: 2
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -2, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Dynamic
Auto Mass: false
Mass: 1
Drag: 0.00999999978
Angular Drag: 0.00999999978
Use Gravity: true
Gravity Scale: 1
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false
Freeze Position Z: false
Freeze Rotation X: false
Freeze Rotation Y: false
Freeze Rotation Z: false
IsActive: true
Collider Component:
Colliders:
- Is Trigger: false
Collision Tag: 0
Type: Sphere
Radius: 1
Friction: 0.400000006
Bounciness: 0
Density: 1
Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true
Scripts: ~

View File

@ -206,7 +206,7 @@ namespace SHADE
{ {
if (PREV_STATE) // Previously inactive if (PREV_STATE) // Previously inactive
broadphase->Insert(shape->id, shape->ComputeAABB()); broadphase->Insert(shape->id, shape->ComputeAABB());
else // Previously active else // Previously active
broadphase->Remove(shape->id); broadphase->Remove(shape->id);
} }
} }

View File

@ -100,7 +100,8 @@ namespace SHADE
shapes.emplace_back(sphere); shapes.emplace_back(sphere);
if (broadphase) // Only add shapes to the broadphase if the collider is active
if (IsActive() && broadphase)
broadphase->Insert(NEW_SHAPE_ID, sphere->ComputeAABB()); broadphase->Insert(NEW_SHAPE_ID, sphere->ComputeAABB());
// Broadcast Event for adding a shape // Broadcast Event for adding a shape
@ -153,7 +154,7 @@ namespace SHADE
shapes.emplace_back(box); shapes.emplace_back(box);
if (broadphase) if (IsActive() && broadphase)
broadphase->Insert(NEW_SHAPE_ID, box->ComputeAABB()); broadphase->Insert(NEW_SHAPE_ID, box->ComputeAABB());
// Broadcast Event for adding a shape // Broadcast Event for adding a shape

View File

@ -87,10 +87,6 @@ namespace SHADE
transformComponent->SetWorldPosition(MOTION_STATE.position); transformComponent->SetWorldPosition(MOTION_STATE.position);
transformComponent->SetWorldOrientation(MOTION_STATE.orientation); transformComponent->SetWorldOrientation(MOTION_STATE.orientation);
} }
/*
* TODO: Test if the scene graph transforms abides by setting world position. Collisions will ignore the scene graph hierarchy.
*/
} }
} }
} }