Fixed some bugs with serialisation
This commit is contained in:
parent
c73275f2d3
commit
36de32447d
|
@ -1,16 +1,2 @@
|
||||||
0 1 3
|
0 1 65535
|
||||||
1 2 65535
|
1 2 65415
|
||||||
2 3 65534
|
|
||||||
3 4 65534
|
|
||||||
4 5 65534
|
|
||||||
5 6 65534
|
|
||||||
6 7 65534
|
|
||||||
7 8 65534
|
|
||||||
8 9 65534
|
|
||||||
9 10 65534
|
|
||||||
10 11 65534
|
|
||||||
11 12 65534
|
|
||||||
12 13 65534
|
|
||||||
13 14 65534
|
|
||||||
14 15 65534
|
|
||||||
15 16 65534
|
|
||||||
|
|
|
@ -135,20 +135,20 @@ Collapsed=0
|
||||||
Column 0 Weight=0.9945
|
Column 0 Weight=0.9945
|
||||||
Column 1 Weight=0.9945
|
Column 1 Weight=0.9945
|
||||||
Column 2 Weight=0.9945
|
Column 2 Weight=0.9945
|
||||||
Column 3 Weight=0.9945
|
Column 3 Weight=1.0320
|
||||||
Column 4 Weight=0.9945
|
Column 4 Weight=0.9570
|
||||||
Column 5 Weight=0.9945
|
Column 5 Weight=0.9945
|
||||||
Column 6 Weight=0.9945
|
Column 6 Weight=0.9945
|
||||||
Column 7 Weight=0.9945
|
Column 7 Weight=0.9945
|
||||||
Column 8 Weight=0.9945
|
Column 8 Weight=0.9945
|
||||||
Column 9 Weight=0.9945
|
Column 9 Weight=1.0320
|
||||||
Column 10 Weight=0.9945
|
Column 10 Weight=0.9570
|
||||||
Column 11 Weight=0.9945
|
Column 11 Weight=1.0133
|
||||||
Column 12 Weight=1.0132
|
Column 12 Weight=0.9945
|
||||||
Column 13 Weight=0.8444
|
Column 13 Weight=0.8444
|
||||||
Column 14 Weight=0.9945
|
Column 14 Weight=0.9945
|
||||||
Column 15 Weight=1.2009
|
Column 15 Weight=1.2009
|
||||||
Column 16 Weight=1.0132
|
Column 16 Weight=1.0133
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X
|
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
Drag: 0.00999999978
|
Drag: 0.00999999978
|
||||||
Angular Drag: 0.100000001
|
Angular Drag: 0.100000001
|
||||||
Use Gravity: false
|
Use Gravity: false
|
||||||
Interpolate: true
|
Interpolate: false
|
||||||
Sleeping Enabled: true
|
Sleeping Enabled: true
|
||||||
Freeze Position X: false
|
Freeze Position X: false
|
||||||
Freeze Position Y: false
|
Freeze Position Y: false
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 1
|
Collision Tag: 2
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 1, y: 1, z: 1}
|
Half Extents: {x: 1, y: 1, z: 1}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 1
|
Collision Tag: 5
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 1, y: 1, z: 1}
|
Half Extents: {x: 1, y: 1, z: 1}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 1
|
Collision Tag: 7
|
||||||
Type: Box
|
Type: Box
|
||||||
Half Extents: {x: 1, y: 1, z: 1}
|
Half Extents: {x: 1, y: 1, z: 1}
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class PhysicsTestObj : Script
|
||||||
{
|
{
|
||||||
Ray colliderRay = new Ray();
|
Ray colliderRay = new Ray();
|
||||||
colliderRay.Direction = Vector3.Right;
|
colliderRay.Direction = Vector3.Right;
|
||||||
Physics.ColliderRaycast(collider.Owner, colliderRay, false, 8);
|
Physics.ColliderRaycast(collider.Owner, colliderRay, false, (ushort)64);
|
||||||
|
|
||||||
for (int i = 0; i < 6; ++i)
|
for (int i = 0; i < 6; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
//#define SHEDITOR
|
//#define SHEDITOR
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
#include "Editor/SHEditor.h"
|
#include "Editor/SHEditor.h"
|
||||||
|
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||||
//#include "Scenes/SBEditorScene.h"
|
//#include "Scenes/SBEditorScene.h"
|
||||||
#endif // SHEDITOR
|
#endif // SHEDITOR
|
||||||
|
|
||||||
|
@ -31,7 +32,6 @@
|
||||||
#include "Input/SHInputManager.h"
|
#include "Input/SHInputManager.h"
|
||||||
#include "Math/Transform/SHTransformSystem.h"
|
#include "Math/Transform/SHTransformSystem.h"
|
||||||
#include "Physics/System/SHPhysicsSystem.h"
|
#include "Physics/System/SHPhysicsSystem.h"
|
||||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
|
||||||
#include "Scripting/SHScriptEngine.h"
|
#include "Scripting/SHScriptEngine.h"
|
||||||
#include "UI/SHUISystem.h"
|
#include "UI/SHUISystem.h"
|
||||||
#include "Animation/SHAnimationSystem.h"
|
#include "Animation/SHAnimationSystem.h"
|
||||||
|
|
|
@ -144,7 +144,13 @@ namespace SHADE
|
||||||
material.SetDensity(density);
|
material.SetDensity(density);
|
||||||
|
|
||||||
if (rp3dCollider)
|
if (rp3dCollider)
|
||||||
|
{
|
||||||
rp3dCollider->getMaterial().setMassDensity(material.GetDensity());
|
rp3dCollider->getMaterial().setMassDensity(material.GetDensity());
|
||||||
|
|
||||||
|
// Recompute the bodies' mass
|
||||||
|
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHCollisionShape::SetMaterial(const SHPhysicsMaterial& newMaterial) noexcept
|
void SHCollisionShape::SetMaterial(const SHPhysicsMaterial& newMaterial) noexcept
|
||||||
|
@ -157,6 +163,9 @@ namespace SHADE
|
||||||
rp3dMaterial.setFrictionCoefficient(material.GetFriction());
|
rp3dMaterial.setFrictionCoefficient(material.GetFriction());
|
||||||
rp3dMaterial.setBounciness(material.GetBounciness());
|
rp3dMaterial.setBounciness(material.GetBounciness());
|
||||||
rp3dMaterial.setMassDensity(material.GetDensity());
|
rp3dMaterial.setMassDensity(material.GetDensity());
|
||||||
|
|
||||||
|
// Recompute the bodies' mass
|
||||||
|
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +189,13 @@ namespace SHADE
|
||||||
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
|
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
|
||||||
|
|
||||||
if (rp3dCollider)
|
if (rp3dCollider)
|
||||||
|
{
|
||||||
rp3dCollider->setIsTrigger(isTrigger);
|
rp3dCollider->setIsTrigger(isTrigger);
|
||||||
|
|
||||||
|
// Recompute the bodies' mass
|
||||||
|
dynamic_cast<rp3d::RigidBody*>(collider->collisionBody)->updateMassPropertiesFromColliders();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -210,9 +210,6 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
.entityID = rigidBody->GetEID()
|
.entityID = rigidBody->GetEID()
|
||||||
, .bodyType = rigidBody->type
|
, .bodyType = rigidBody->type
|
||||||
, .interpolate = rigidBody->interpolate
|
|
||||||
, .drag = rigidBody->drag
|
|
||||||
, .angularDrag = rigidBody->angularDrag
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rigidBodyQueue.push(RIGID_BODY_DEF);
|
rigidBodyQueue.push(RIGID_BODY_DEF);
|
||||||
|
@ -232,22 +229,8 @@ namespace SHADE
|
||||||
SHColliderDef::ShapeDef shapeDef
|
SHColliderDef::ShapeDef shapeDef
|
||||||
{
|
{
|
||||||
.type = shape->GetType()
|
.type = shape->GetType()
|
||||||
, .posOffset = shape->GetPositionOffset()
|
|
||||||
, .rotOffset = shape->GetRotationOffset()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (shape->GetType())
|
|
||||||
{
|
|
||||||
case SHCollisionShape::Type::SPHERE:
|
|
||||||
shapeDef.size.x = dynamic_cast<const SHSphere*>(shape)->GetWorldRadius();
|
|
||||||
break;
|
|
||||||
case SHCollisionShape::Type::BOX:
|
|
||||||
shapeDef.size = dynamic_cast<const SHBox*>(shape)->GetWorldExtents();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
colliderDef.shapes.emplace_back(shapeDef);
|
colliderDef.shapes.emplace_back(shapeDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,9 +294,9 @@ namespace SHADE
|
||||||
rigidBodyComponent->SetFreezeRotationY (rigidBodyComponent->GetFreezeRotationY());
|
rigidBodyComponent->SetFreezeRotationY (rigidBodyComponent->GetFreezeRotationY());
|
||||||
rigidBodyComponent->SetFreezeRotationZ (rigidBodyComponent->GetFreezeRotationZ());
|
rigidBodyComponent->SetFreezeRotationZ (rigidBodyComponent->GetFreezeRotationZ());
|
||||||
|
|
||||||
rigidBodyComponent->SetInterpolate (DEF.interpolate);
|
rigidBodyComponent->SetInterpolate (rigidBodyComponent->IsInterpolating());
|
||||||
rigidBodyComponent->SetDrag (DEF.drag);
|
rigidBodyComponent->SetDrag (rigidBodyComponent->GetDrag());
|
||||||
rigidBodyComponent->SetAngularDrag (DEF.angularDrag);
|
rigidBodyComponent->SetAngularDrag (rigidBodyComponent->GetAngularDrag());
|
||||||
|
|
||||||
rigidBodyQueue.pop();
|
rigidBodyQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,6 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
EntityID entityID = MAX_EID;
|
EntityID entityID = MAX_EID;
|
||||||
SHRigidBodyComponent::Type bodyType = SHRigidBodyComponent::Type::STATIC;
|
SHRigidBodyComponent::Type bodyType = SHRigidBodyComponent::Type::STATIC;
|
||||||
bool interpolate = true;
|
|
||||||
float drag = 0.0f;
|
|
||||||
float angularDrag = 0.0f;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SHColliderDef
|
struct SHColliderDef
|
||||||
|
@ -57,9 +54,6 @@ namespace SHADE
|
||||||
struct ShapeDef
|
struct ShapeDef
|
||||||
{
|
{
|
||||||
SHCollisionShape::Type type = SHCollisionShape::Type::SPHERE;
|
SHCollisionShape::Type type = SHCollisionShape::Type::SPHERE;
|
||||||
SHVec3 posOffset = SHVec3::Zero;
|
|
||||||
SHVec3 rotOffset = SHVec3::Zero;
|
|
||||||
SHVec3 size = SHVec3::Zero; // x for sphere radius, all 3 for box extents
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EntityID entityID = MAX_EID;
|
EntityID entityID = MAX_EID;
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace SHADE
|
||||||
/* Friends */
|
/* Friends */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
friend class SHCollisionShape;
|
||||||
friend class SHPhysicsSystem;
|
friend class SHPhysicsSystem;
|
||||||
friend class SHPhysicsObjectManager;
|
friend class SHPhysicsObjectManager;
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace SHADE
|
||||||
// Load start and end points into the container for debug drawing
|
// Load start and end points into the container for debug drawing
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
|
|
||||||
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
|
SHVec3 endPos = info.ray.position + info.ray.direction * std::clamp(info.distance, 0.0f, SHRay::MAX_RAYCAST_DIST);
|
||||||
|
|
||||||
if (!results.empty())
|
if (!results.empty())
|
||||||
endPos = results.back().position;
|
endPos = results.back().position;
|
||||||
|
|
Loading…
Reference in New Issue