Fixed various physics bugs and added Physics Material to Inspector #249
|
@ -4,7 +4,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Camera Component:
|
Camera Component:
|
||||||
Position: {x: 0, y: 0, z: 8}
|
Position: {x: 0, y: 3, z: 8}
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 0
|
Yaw: 0
|
||||||
Roll: 0
|
Roll: 0
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
Near: 0.00999999978
|
Near: 0.00999999978
|
||||||
Far: 10000
|
Far: 10000
|
||||||
Perspective: true
|
Perspective: true
|
||||||
|
IsActive: true
|
||||||
Light Component:
|
Light Component:
|
||||||
Position: {x: 0, y: 0, z: 0}
|
Position: {x: 0, y: 0, z: 0}
|
||||||
Type: Directional
|
Type: Directional
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
Color: {x: 0.951541841, y: 0.921719015, z: 0.553319454, w: 1}
|
Color: {x: 0.951541841, y: 0.921719015, z: 0.553319454, w: 1}
|
||||||
Layer: 4294967295
|
Layer: 4294967295
|
||||||
Strength: 0
|
Strength: 0
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 7
|
- EID: 7
|
||||||
Name: BigBoi
|
Name: BigBoi
|
||||||
|
@ -30,9 +32,11 @@
|
||||||
Translate: {x: 0, y: -16.8647861, z: -14.039052}
|
Translate: {x: 0, y: -16.8647861, z: -14.039052}
|
||||||
Rotate: {x: -0, y: 0, z: -0}
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
Scale: {x: 28.1434975, y: 28.1434975, z: 28.1434975}
|
Scale: {x: 28.1434975, y: 28.1434975, z: 28.1434975}
|
||||||
|
IsActive: true
|
||||||
Renderable Component:
|
Renderable Component:
|
||||||
Mesh: 149697411
|
Mesh: 149697411
|
||||||
Material: 126974645
|
Material: 126974645
|
||||||
|
IsActive: true
|
||||||
Scripts: ~
|
Scripts: ~
|
||||||
- EID: 8
|
- EID: 8
|
||||||
Name: AmbientLight
|
Name: AmbientLight
|
||||||
|
@ -46,4 +50,335 @@
|
||||||
Color: {x: 1, y: 1, z: 1, w: 1}
|
Color: {x: 1, y: 1, z: 1, w: 1}
|
||||||
Layer: 4294967295
|
Layer: 4294967295
|
||||||
Strength: 0.25
|
Strength: 0.25
|
||||||
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 65542
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.5, y: 0.5, z: -2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 65538
|
||||||
|
Name: Movable
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 4.28833103, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
RigidBody Component:
|
||||||
|
Type: Dynamic
|
||||||
|
Drag: 0.00999999978
|
||||||
|
Angular Drag: 0.00999999978
|
||||||
|
Use Gravity: true
|
||||||
|
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
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 1}
|
||||||
|
Friction: 0.400000006
|
||||||
|
Bounciness: 0
|
||||||
|
Density: 1
|
||||||
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 2, y: 2, z: 2}
|
||||||
|
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: ~
|
||||||
|
- EID: 65537
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 5.25, y: 2.75, z: 2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 1.57079637}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 9
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 5.25, y: 2.75, z: -2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 1.57079637}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 10
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -5.25, y: 2.75, z: 2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 1.57079637}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 11
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -5.25, y: 2.75, z: -2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 1.57079637}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 12
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.5, y: 2.75, z: 5.25}
|
||||||
|
Rotate: {x: 7.15255737e-07, y: 1.57079566, z: 1.57079589}
|
||||||
|
Scale: {x: 4.99999809, y: 0.499999762, z: 4.99999809}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 65551
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -2.5, y: 2.75, z: 5.25}
|
||||||
|
Rotate: {x: 7.15255737e-07, y: 1.57079566, z: 1.57079589}
|
||||||
|
Scale: {x: 4.99999809, y: 0.499999762, z: 4.99999809}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 65550
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -2.5, y: 2.75, z: -5.25}
|
||||||
|
Rotate: {x: 7.15255737e-07, y: 1.57079566, z: 1.57079589}
|
||||||
|
Scale: {x: 4.99999809, y: 0.499999762, z: 4.99999809}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 65549
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.5, y: 2.75, z: -5.25}
|
||||||
|
Rotate: {x: 7.15255737e-07, y: 1.57079566, z: 1.57079589}
|
||||||
|
Scale: {x: 4.99999809, y: 0.499999762, z: 4.99999809}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 16
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 0, y: 2.5, z: 0}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 2.5, y: 0.5, z: 2.5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 5
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 2.5, y: 0.5, z: 2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 4
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -2.5, y: 0.5, z: -2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
||||||
|
- EID: 3
|
||||||
|
Name: Default
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: -2.5, y: 0.5, z: 2.5}
|
||||||
|
Rotate: {x: 0, y: 0, z: 0}
|
||||||
|
Scale: {x: 5, y: 0.5, z: 5}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Type: Box
|
||||||
|
Half Extents: {x: 1, y: 1, z: 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: ~
|
Scripts: ~
|
|
@ -44,6 +44,8 @@ namespace Sandbox
|
||||||
{
|
{
|
||||||
sceneName = SHSerialization::DeserializeSceneFromFile(sceneAssetID);
|
sceneName = SHSerialization::DeserializeSceneFromFile(sceneAssetID);
|
||||||
|
|
||||||
|
#ifndef SHEDITOR
|
||||||
|
|
||||||
auto* physicsSystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
auto* physicsSystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
||||||
if (!physicsSystem)
|
if (!physicsSystem)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +55,8 @@ namespace Sandbox
|
||||||
|
|
||||||
physicsSystem->BuildScene(SHSceneManager::GetCurrentSceneGraph());
|
physicsSystem->BuildScene(SHSceneManager::GetCurrentSceneGraph());
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* TESTING CODE */
|
/* TESTING CODE */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
|
@ -333,10 +333,10 @@ namespace SHADE
|
||||||
auto cursorPos = ImGui::GetCursorPos();
|
auto cursorPos = ImGui::GetCursorPos();
|
||||||
|
|
||||||
//collider->IsTrigger
|
//collider->IsTrigger
|
||||||
|
|
||||||
if (collider->GetType() == SHCollisionShape::Type::BOX)
|
if (collider->GetType() == SHCollisionShape::Type::BOX)
|
||||||
{
|
{
|
||||||
SHEditorWidgets::BeginPanel(std::format("{} Box #{}", ICON_FA_CUBE, i).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
|
SHEditorWidgets::BeginPanel(std::format("{} Box #{}", ICON_FA_CUBE, i).data(), { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y });
|
||||||
|
|
||||||
const auto* BOX = reinterpret_cast<const SHBox*>(collider->GetShape());
|
const auto* BOX = reinterpret_cast<const SHBox*>(collider->GetShape());
|
||||||
SHEditorWidgets::DragVec3
|
SHEditorWidgets::DragVec3
|
||||||
(
|
(
|
||||||
|
@ -360,6 +360,15 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
SHEditorWidgets::CheckBox("Is Trigger", [collider] { return collider->IsTrigger(); }, [collider](bool value) { collider->SetIsTrigger(value); });
|
||||||
|
|
||||||
|
if(ImGui::CollapsingHeader("Physics Material"))
|
||||||
|
{
|
||||||
|
SHEditorWidgets::DragFloat("Friction", [collider] { return collider->GetFriction(); }, [collider](float value) { collider->SetFriction(value); }, "Friction", 0.05f, 0.0f, 1.0f);
|
||||||
|
SHEditorWidgets::DragFloat("Bounciness", [collider] { return collider->GetBounciness(); }, [collider](float value) { collider->SetBounciness(value); }, "Bounciness", 0.05f, 0.0f, 1.0f);
|
||||||
|
SHEditorWidgets::DragFloat("Mass Density", [collider] { return collider->GetDensity(); }, [collider](float value) { collider->SetDensity(value); }, "Mass Density", 0.1f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
|
SHEditorWidgets::BeginPanel("Offsets",{ ImGui::GetContentRegionAvail().x, 30.0f });
|
||||||
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&collider] {return collider->GetPositionOffset(); }, [&collider](SHVec3 const& vec) {collider->SetPositionOffset(vec); });
|
SHEditorWidgets::DragVec3("Position", { "X", "Y", "Z" }, [&collider] {return collider->GetPositionOffset(); }, [&collider](SHVec3 const& vec) {collider->SetPositionOffset(vec); });
|
||||||
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
|
SHEditorWidgets::DragVec3("Rotation", { "X", "Y", "Z" },
|
||||||
|
@ -375,8 +384,6 @@ namespace SHADE
|
||||||
SHEditorWidgets::EndPanel();
|
SHEditorWidgets::EndPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
SHEditorWidgets::CheckBox("Is Trigger", [collider] { return collider->IsTrigger(); }, [collider](bool value) { collider->SetIsTrigger(value); });
|
|
||||||
|
|
||||||
if (ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
|
if (ImGui::Button(std::format("{} Remove Collider #{}", ICON_MD_REMOVE, i).data()))
|
||||||
{
|
{
|
||||||
colliderToDelete = i;
|
colliderToDelete = i;
|
||||||
|
|
|
@ -359,6 +359,10 @@ RTTR_REGISTRATION
|
||||||
);
|
);
|
||||||
|
|
||||||
registration::class_<SHCollisionShape>("Collider")
|
registration::class_<SHCollisionShape>("Collider")
|
||||||
|
.property("IsTrigger" , &SHCollisionShape::IsTrigger , &SHCollisionShape::SetIsTrigger )
|
||||||
|
.property("Friction" , &SHCollisionShape::GetFriction , &SHCollisionShape::SetFriction )
|
||||||
|
.property("Bounciness" , &SHCollisionShape::GetBounciness , &SHCollisionShape::SetBounciness )
|
||||||
|
.property("Density" , &SHCollisionShape::GetDensity , &SHCollisionShape::SetDensity )
|
||||||
.property("Position Offset" , &SHCollisionShape::GetPositionOffset, &SHCollisionShape::SetPositionOffset)
|
.property("Position Offset" , &SHCollisionShape::GetPositionOffset, &SHCollisionShape::SetPositionOffset)
|
||||||
.property("Rotation Offset" , &SHCollisionShape::GetRotationOffset, &SHCollisionShape::SetRotationOffset) (metadata(META::angleInRad, true));
|
.property("Rotation Offset" , &SHCollisionShape::GetRotationOffset, &SHCollisionShape::SetRotationOffset) (metadata(META::angleInRad, true));
|
||||||
}
|
}
|
|
@ -123,12 +123,14 @@ namespace SHADE
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto* rp3dCollider = rp3dBody->getCollider(rp3dBody->getNbColliders() - 1);
|
||||||
|
syncColliderProperties(collisionShape, rp3dCollider);
|
||||||
|
|
||||||
if (rp3dBody->getType() == rp3d::BodyType::DYNAMIC)
|
if (rp3dBody->getType() == rp3d::BodyType::DYNAMIC)
|
||||||
{
|
{
|
||||||
rp3dBody->updateMassPropertiesFromColliders();
|
rp3dBody->updateMassPropertiesFromColliders();
|
||||||
|
|
||||||
auto* rigidBodyComponent = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(entityID);
|
if (auto* rigidBodyComponent = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(entityID); rigidBodyComponent)
|
||||||
if (rigidBodyComponent)
|
|
||||||
rigidBodyComponent->mass = rp3dBody->getMass();
|
rigidBodyComponent->mass = rp3dBody->getMass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,28 +328,42 @@ namespace SHADE
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync material
|
|
||||||
auto* rp3dCollider = rp3dBody->getCollider(i);
|
auto* rp3dCollider = rp3dBody->getCollider(i);
|
||||||
auto& rp3dMaterial = rp3dCollider->getMaterial();
|
syncColliderProperties(collisionShape, rp3dCollider);
|
||||||
|
|
||||||
rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction());
|
|
||||||
rp3dMaterial.setBounciness(collisionShape.GetBounciness());
|
|
||||||
rp3dMaterial.setMassDensity(collisionShape.GetDensity());
|
|
||||||
|
|
||||||
// Sync tags
|
|
||||||
const unsigned short MASK_BITS = collisionShape.GetCollisionTag();
|
|
||||||
rp3dCollider->setCollisionCategoryBits(MASK_BITS);
|
|
||||||
rp3dCollider->setCollideWithMaskBits(MASK_BITS);
|
|
||||||
|
|
||||||
collisionShape.dirty = false;
|
collisionShape.dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set rigidbody mass if dynamic
|
||||||
|
auto* rigidBodyComponent = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(entityID);
|
||||||
|
if (rigidBodyComponent)
|
||||||
|
{
|
||||||
|
// This is generally expensive, will be optimised in the future with my own engine.
|
||||||
|
rp3dBody->updateMassPropertiesFromColliders();
|
||||||
|
rigidBodyComponent->mass = rp3dBody->getMass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Private Function Member Definitions */
|
/* Private Function Member Definitions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void SHPhysicsObject::addBoxShape(SHCollisionShape& boxShape) const noexcept
|
void SHPhysicsObject::syncColliderProperties(const SHCollisionShape& collisionShape, rp3d::Collider* rp3dCollider) const noexcept
|
||||||
|
{
|
||||||
|
rp3dCollider->setIsTrigger(collisionShape.IsTrigger());
|
||||||
|
|
||||||
|
auto& rp3dMaterial = rp3dCollider->getMaterial();
|
||||||
|
|
||||||
|
rp3dMaterial.setFrictionCoefficient(collisionShape.GetFriction());
|
||||||
|
rp3dMaterial.setBounciness(collisionShape.GetBounciness());
|
||||||
|
rp3dMaterial.setMassDensity(collisionShape.GetDensity());
|
||||||
|
|
||||||
|
const unsigned short MASK_BITS = collisionShape.GetCollisionTag();
|
||||||
|
rp3dCollider->setCollisionCategoryBits(MASK_BITS);
|
||||||
|
rp3dCollider->setCollideWithMaskBits(MASK_BITS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHPhysicsObject::addBoxShape(const SHCollisionShape& boxShape) const noexcept
|
||||||
{
|
{
|
||||||
const rp3d::Transform OFFSETS
|
const rp3d::Transform OFFSETS
|
||||||
{
|
{
|
||||||
|
@ -361,7 +377,7 @@ namespace SHADE
|
||||||
rp3dBody->addCollider(newBox, OFFSETS);
|
rp3dBody->addCollider(newBox, OFFSETS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHPhysicsObject::syncBoxShape(int index, SHCollisionShape& boxShape) const noexcept
|
void SHPhysicsObject::syncBoxShape(int index, const SHCollisionShape& boxShape) const noexcept
|
||||||
{
|
{
|
||||||
const auto* BOX = reinterpret_cast<const SHBox*>(boxShape.GetShape());
|
const auto* BOX = reinterpret_cast<const SHBox*>(boxShape.GetShape());
|
||||||
|
|
||||||
|
@ -380,7 +396,7 @@ namespace SHADE
|
||||||
rp3dBox->setHalfExtents(BOX->GetWorldExtents());
|
rp3dBox->setHalfExtents(BOX->GetWorldExtents());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHPhysicsObject::addSphereShape(SHCollisionShape& sphereShape) const noexcept
|
void SHPhysicsObject::addSphereShape(const SHCollisionShape& sphereShape) const noexcept
|
||||||
{
|
{
|
||||||
const rp3d::Transform OFFSETS
|
const rp3d::Transform OFFSETS
|
||||||
{
|
{
|
||||||
|
@ -394,7 +410,7 @@ namespace SHADE
|
||||||
rp3dBody->addCollider(newSphere, OFFSETS);
|
rp3dBody->addCollider(newSphere, OFFSETS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHPhysicsObject::syncSphereShape(int index, SHCollisionShape& sphereShape) const noexcept
|
void SHPhysicsObject::syncSphereShape(int index, const SHCollisionShape& sphereShape) const noexcept
|
||||||
{
|
{
|
||||||
const auto* SPHERE = reinterpret_cast<const SHSphere*>(sphereShape.GetShape());
|
const auto* SPHERE = reinterpret_cast<const SHSphere*>(sphereShape.GetShape());
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,16 @@ namespace SHADE
|
||||||
/* Function Members */
|
/* Function Members */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void syncColliderProperties (const SHCollisionShape& collisionShape, rp3d::Collider* rp3dCollider) const noexcept;
|
||||||
|
|
||||||
// Box Shapes
|
// Box Shapes
|
||||||
|
|
||||||
void addBoxShape (SHCollisionShape& boxShape) const noexcept;
|
void addBoxShape (const SHCollisionShape& boxShape) const noexcept;
|
||||||
void syncBoxShape (int index, SHCollisionShape& boxShape) const noexcept;
|
void syncBoxShape (int index, const SHCollisionShape& boxShape) const noexcept;
|
||||||
|
|
||||||
// Sphere Shapes
|
// Sphere Shapes
|
||||||
|
|
||||||
void addSphereShape (SHCollisionShape& sphereShape) const noexcept;
|
void addSphereShape (const SHCollisionShape& sphereShape) const noexcept;
|
||||||
void syncSphereShape (int index, SHCollisionShape& sphereShape) const noexcept;
|
void syncSphereShape (int index, const SHCollisionShape& sphereShape) const noexcept;
|
||||||
};
|
};
|
||||||
} // namespace SHADE
|
} // namespace SHADE
|
|
@ -21,6 +21,14 @@
|
||||||
|
|
||||||
#include "Input/SHInputManager.h"
|
#include "Input/SHInputManager.h"
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------*/
|
||||||
|
/* Local Functions */
|
||||||
|
/*-------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void testFunction();
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -134,6 +142,8 @@ namespace SHADE
|
||||||
const double FIXED_DT = physicsSystem->fixedDT;
|
const double FIXED_DT = physicsSystem->fixedDT;
|
||||||
accumulatedTime += dt;
|
accumulatedTime += dt;
|
||||||
|
|
||||||
|
//testFunction();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (accumulatedTime > FIXED_DT)
|
while (accumulatedTime > FIXED_DT)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +325,7 @@ namespace SHADE
|
||||||
if (physicsObject.GetRigidBody()->isActive())
|
if (physicsObject.GetRigidBody()->isActive())
|
||||||
physicsObject.prevTransform = CURRENT_TF;
|
physicsObject.prevTransform = CURRENT_TF;
|
||||||
|
|
||||||
// Sync with rigid bodies
|
// Sync with rigid bodies. If an object doesn't have a rigidbody, no update is needed here as it is done in pre-update.
|
||||||
if (rigidBodyComponent && SHSceneManager::CheckNodeAndComponentsActive<SHRigidBodyComponent>(physicsObject.entityID))
|
if (rigidBodyComponent && SHSceneManager::CheckNodeAndComponentsActive<SHRigidBodyComponent>(physicsObject.entityID))
|
||||||
{
|
{
|
||||||
// Skip static bodies
|
// Skip static bodies
|
||||||
|
@ -336,11 +346,12 @@ namespace SHADE
|
||||||
|
|
||||||
rigidBodyComponent->position = CURRENT_TF.getPosition();
|
rigidBodyComponent->position = CURRENT_TF.getPosition();
|
||||||
rigidBodyComponent->orientation = CURRENT_TF.getOrientation();
|
rigidBodyComponent->orientation = CURRENT_TF.getOrientation();
|
||||||
}
|
|
||||||
|
|
||||||
// Sync with colliders
|
// Sync with colliders
|
||||||
if (colliderComponent && SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(physicsObject.entityID))
|
if (colliderComponent && SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(physicsObject.entityID))
|
||||||
{
|
{
|
||||||
|
// Skip colliders without rigidbody components. If any transform was updated, it was done in pre-update.
|
||||||
|
|
||||||
colliderComponent->position = CURRENT_TF.getPosition();
|
colliderComponent->position = CURRENT_TF.getPosition();
|
||||||
colliderComponent->orientation = CURRENT_TF.getOrientation();
|
colliderComponent->orientation = CURRENT_TF.getOrientation();
|
||||||
}
|
}
|
||||||
|
@ -352,4 +363,35 @@ namespace SHADE
|
||||||
transformComponent->SetWorldOrientation(renderRot);
|
transformComponent->SetWorldOrientation(renderRot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // namespace SHADE
|
} // namespace SHADE
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void testFunction()
|
||||||
|
{
|
||||||
|
using namespace SHADE;
|
||||||
|
|
||||||
|
// Test movement
|
||||||
|
const float forceModifier = 25.0f;
|
||||||
|
EntityID eid = 65538;
|
||||||
|
|
||||||
|
if (SHEntityManager::IsValidEID(eid))
|
||||||
|
{
|
||||||
|
auto* rb = SHComponentManager::GetComponent_s<SHRigidBodyComponent>(eid);
|
||||||
|
if (rb)
|
||||||
|
{
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::W))
|
||||||
|
rb->AddForce(-SHVec3::UnitZ * forceModifier);
|
||||||
|
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::A))
|
||||||
|
rb->AddForce(-SHVec3::UnitX * forceModifier);
|
||||||
|
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::S))
|
||||||
|
rb->AddForce(SHVec3::UnitZ * forceModifier);
|
||||||
|
|
||||||
|
if (SHInputManager::GetKey(SHInputManager::SH_KEYCODE::D))
|
||||||
|
rb->AddForce(SHVec3::UnitX * forceModifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ namespace YAML
|
||||||
if (node[Friction].IsDefined())
|
if (node[Friction].IsDefined())
|
||||||
rhs.SetFriction(node[Friction].as<float>());
|
rhs.SetFriction(node[Friction].as<float>());
|
||||||
if (node[Bounciness].IsDefined())
|
if (node[Bounciness].IsDefined())
|
||||||
rhs.SetBounciness(rhs.GetBounciness());
|
rhs.SetBounciness(node[Bounciness].as<float>());
|
||||||
if (node[Density].IsDefined())
|
if (node[Density].IsDefined())
|
||||||
rhs.SetDensity(node[Density].as<float>());
|
rhs.SetDensity(node[Density].as<float>());
|
||||||
if (node[PositionOffset].IsDefined())
|
if (node[PositionOffset].IsDefined())
|
||||||
|
|
Loading…
Reference in New Issue