Fixed bug where box colliders weren't being deleted on scene destroy
This commit is contained in:
parent
991912f7b4
commit
e43089e6ff
|
@ -1,4 +1,4 @@
|
||||||
Start Maximized: true
|
Start Maximized: true
|
||||||
Working Scene ID: 97402985
|
Working Scene ID: 92914350
|
||||||
Window Size: {x: 2000, y: 1518}
|
Window Size: {x: 2000, y: 1518}
|
||||||
Style: 0
|
Style: 0
|
|
@ -251,9 +251,9 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 2, y: 5, z: 3}
|
Translate: {x: 2.35593724, y: 3, z: 3}
|
||||||
Rotate: {x: 0, y: 0, z: 0.785398185}
|
Rotate: {x: -0, y: 0.785398006, z: -0}
|
||||||
Scale: {x: 0.999999642, y: 0.999998569, z: 0.999999642}
|
Scale: {x: 0.999999702, y: 0.999998569, z: 0.999999702}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Camera Component:
|
Camera Component:
|
||||||
Position: {x: 0, y: 1, z: 5}
|
Position: {x: 1, y: -0.5, z: 5}
|
||||||
Pitch: 0
|
Pitch: 0
|
||||||
Yaw: 0
|
Yaw: 0
|
||||||
Roll: 0
|
Roll: 0
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 1
|
Collision Tag: 1
|
||||||
Type: Box
|
Type: Sphere
|
||||||
Half Extents: {x: 1, y: 1, z: 1}
|
Radius: 1
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 1.5, y: 2, z: 1.5}
|
Translate: {x: 0, y: 5, z: 0}
|
||||||
Rotate: {x: 0, y: 0.785398185, z: 0}
|
Rotate: {x: -0, y: 0.785398006, z: -0}
|
||||||
Scale: {x: 1, y: 1, z: 1}
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
|
@ -71,8 +71,8 @@
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 1
|
Collision Tag: 1
|
||||||
Type: Box
|
Type: Sphere
|
||||||
Half Extents: {x: 1, y: 1, z: 1}
|
Radius: 1
|
||||||
Friction: 0.400000006
|
Friction: 0.400000006
|
||||||
Bounciness: 0
|
Bounciness: 0
|
||||||
Density: 1
|
Density: 1
|
||||||
|
@ -83,4 +83,4 @@
|
||||||
- Type: PhysicsTestObj
|
- Type: PhysicsTestObj
|
||||||
Enabled: true
|
Enabled: true
|
||||||
forceAmount: 50
|
forceAmount: 50
|
||||||
torqueAmount: 500
|
torqueAmount: 25
|
|
@ -64,8 +64,37 @@ public class PhysicsTestObj : Script
|
||||||
};
|
};
|
||||||
|
|
||||||
public float forceAmount = 50.0f;
|
public float forceAmount = 50.0f;
|
||||||
public float torqueAmount = 500.0f;
|
public float torqueAmount = 25.0f;
|
||||||
|
|
||||||
|
protected override void onTriggerEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Trigger Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onTriggerStay(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Trigger Stay");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onTriggerExit(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Trigger Exit");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Collision Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionStay(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Collision Stay");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionExit(CollisionInfo info)
|
||||||
|
{
|
||||||
|
Debug.Log("Collision Exit");
|
||||||
|
}
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
body = GetComponent<RigidBody>();
|
body = GetComponent<RigidBody>();
|
||||||
|
|
|
@ -92,14 +92,6 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHCollisionShape::IsTrigger() const noexcept
|
bool SHCollisionShape::IsTrigger() const noexcept
|
||||||
{
|
|
||||||
static constexpr int FLAG_POS = 3;
|
|
||||||
static constexpr uint8_t FLAG_VALUE = 1U << FLAG_POS;
|
|
||||||
|
|
||||||
return flags & FLAG_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SHCollisionShape::IsColliding() const noexcept
|
|
||||||
{
|
{
|
||||||
static constexpr int FLAG_POS = 4;
|
static constexpr int FLAG_POS = 4;
|
||||||
static constexpr uint8_t FLAG_VALUE = 1U << FLAG_POS;
|
static constexpr uint8_t FLAG_VALUE = 1U << FLAG_POS;
|
||||||
|
@ -158,7 +150,7 @@ namespace SHADE
|
||||||
|
|
||||||
void SHCollisionShape::SetIsTrigger(bool isTrigger) noexcept
|
void SHCollisionShape::SetIsTrigger(bool isTrigger) noexcept
|
||||||
{
|
{
|
||||||
static constexpr int FLAG_POS = 3;
|
static constexpr int FLAG_POS = 4;
|
||||||
static constexpr uint8_t FLAG_VALUE = 1U << FLAG_POS;
|
static constexpr uint8_t FLAG_VALUE = 1U << FLAG_POS;
|
||||||
|
|
||||||
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
|
isTrigger ? flags |= FLAG_VALUE : flags &= ~FLAG_VALUE;
|
||||||
|
|
|
@ -105,7 +105,6 @@ namespace SHADE
|
||||||
|
|
||||||
[[nodiscard]] Type GetType () const noexcept;
|
[[nodiscard]] Type GetType () const noexcept;
|
||||||
[[nodiscard]] bool IsTrigger () const noexcept;
|
[[nodiscard]] bool IsTrigger () const noexcept;
|
||||||
[[nodiscard]] bool IsColliding () const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] const SHCollisionTag& GetCollisionTag () const noexcept;
|
[[nodiscard]] const SHCollisionTag& GetCollisionTag () const noexcept;
|
||||||
|
|
||||||
|
@ -201,7 +200,7 @@ namespace SHADE
|
||||||
// Needed for conversion to euler angles
|
// Needed for conversion to euler angles
|
||||||
SHVec3 rotationOffset;
|
SHVec3 rotationOffset;
|
||||||
|
|
||||||
uint8_t flags; // 0 0 0 trigger convexHull capsule sphere box
|
uint8_t flags; // 0 0 0 trigger convexHull capsule box sphere
|
||||||
|
|
||||||
|
|
||||||
RTTR_ENABLE()
|
RTTR_ENABLE()
|
||||||
|
|
|
@ -86,6 +86,12 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
case SHCollisionShape::Type::BOX:
|
case SHCollisionShape::Type::BOX:
|
||||||
{
|
{
|
||||||
|
SHBox* box = boxes.find(shape->id)->second;
|
||||||
|
boxes.erase(shape->id);
|
||||||
|
|
||||||
|
delete box;
|
||||||
|
box = nullptr;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHCollisionShape::Type::SPHERE:
|
case SHCollisionShape::Type::SPHERE:
|
||||||
|
|
|
@ -159,6 +159,8 @@ namespace SHADE
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHLOG_INFO("State {}", static_cast<int>(manifold.state))
|
||||||
|
|
||||||
updateManifold(manifold, oldManifold);
|
updateManifold(manifold, oldManifold);
|
||||||
++manifoldPair;
|
++manifoldPair;
|
||||||
}
|
}
|
||||||
|
@ -167,12 +169,11 @@ namespace SHADE
|
||||||
for (auto triggerPair = triggers.begin(); triggerPair != triggers.end();)
|
for (auto triggerPair = triggers.begin(); triggerPair != triggers.end();)
|
||||||
{
|
{
|
||||||
// Test collision of every trigger.
|
// Test collision of every trigger.
|
||||||
Trigger& oldTrigger = triggerPair->second;
|
Trigger& trigger = triggerPair->second;
|
||||||
Trigger newTrigger = oldTrigger;
|
|
||||||
|
|
||||||
const bool IS_COLLIDING = SHCollisionDispatcher::Collide(*newTrigger.A, *newTrigger.B);
|
const bool IS_COLLIDING = SHCollisionDispatcher::Collide(*trigger.A, *trigger.B);
|
||||||
|
|
||||||
auto& collisionState = newTrigger.state;
|
auto& collisionState = trigger.state;
|
||||||
updateCollisionState(IS_COLLIDING, collisionState);
|
updateCollisionState(IS_COLLIDING, collisionState);
|
||||||
|
|
||||||
const bool IS_INVALID = collisionState == SHCollisionState::INVALID;
|
const bool IS_INVALID = collisionState == SHCollisionState::INVALID;
|
||||||
|
|
|
@ -94,8 +94,6 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Collision & Trigger messages
|
// Collision & Trigger messages
|
||||||
if (scriptingSystem != nullptr)
|
if (scriptingSystem != nullptr)
|
||||||
scriptingSystem->ExecuteCollisionFunctions();
|
scriptingSystem->ExecuteCollisionFunctions();
|
||||||
|
|
Loading…
Reference in New Issue