Potential fix for incorrect collision states #350
|
@ -1,18 +1,18 @@
|
||||||
- EID: 0
|
- EID: 0
|
||||||
Name: Default
|
Name: Player
|
||||||
IsActive: true
|
IsActive: true
|
||||||
NumberOfChildren: 0
|
NumberOfChildren: 0
|
||||||
Components:
|
Components:
|
||||||
Transform Component:
|
Transform Component:
|
||||||
Translate: {x: 0, y: 7, z: 0}
|
Translate: {x: 0, y: 7, z: 0}
|
||||||
Rotate: {x: 0, y: 0, z: 0}
|
Rotate: {x: 1.48352981, y: 0, z: 0}
|
||||||
Scale: {x: 0.999999344, y: 0.999999821, z: 0.999999523}
|
Scale: {x: 0.999999344, y: 0.999999821, z: 0.999999523}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
RigidBody Component:
|
RigidBody Component:
|
||||||
Type: Dynamic
|
Type: Dynamic
|
||||||
Drag: 0.00999999978
|
Drag: 0.00999999978
|
||||||
Angular Drag: 0.100000001
|
Angular Drag: 0.100000001
|
||||||
Use Gravity: false
|
Use Gravity: true
|
||||||
Interpolate: false
|
Interpolate: false
|
||||||
Sleeping Enabled: true
|
Sleeping Enabled: true
|
||||||
Freeze Position X: false
|
Freeze Position X: false
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 2
|
Collision Tag: 0
|
||||||
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
|
||||||
|
@ -39,6 +39,8 @@
|
||||||
Enabled: true
|
Enabled: true
|
||||||
forceAmount: 50
|
forceAmount: 50
|
||||||
torqueAmount: 500
|
torqueAmount: 500
|
||||||
|
- Type: CollisionTest
|
||||||
|
Enabled: true
|
||||||
- EID: 1
|
- EID: 1
|
||||||
Name: Default
|
Name: Default
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
@ -52,7 +54,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 5
|
Collision Tag: 0
|
||||||
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 +163,7 @@
|
||||||
Collider Component:
|
Collider Component:
|
||||||
Colliders:
|
Colliders:
|
||||||
- Is Trigger: false
|
- Is Trigger: false
|
||||||
Collision Tag: 7
|
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
|
||||||
|
@ -207,4 +209,27 @@
|
||||||
Position Offset: {x: 0, y: 0, z: 0}
|
Position Offset: {x: 0, y: 0, z: 0}
|
||||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||||
IsActive: true
|
IsActive: true
|
||||||
|
Scripts: ~
|
||||||
|
- EID: 8
|
||||||
|
Name: Target
|
||||||
|
IsActive: true
|
||||||
|
NumberOfChildren: 0
|
||||||
|
Components:
|
||||||
|
Transform Component:
|
||||||
|
Translate: {x: 8, y: 7, z: 0}
|
||||||
|
Rotate: {x: -0, y: 0, z: -0}
|
||||||
|
Scale: {x: 1, y: 1, z: 1}
|
||||||
|
IsActive: true
|
||||||
|
Collider Component:
|
||||||
|
Colliders:
|
||||||
|
- Is Trigger: false
|
||||||
|
Collision Tag: 0
|
||||||
|
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: ~
|
|
@ -0,0 +1,45 @@
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using static Item;
|
||||||
|
|
||||||
|
|
||||||
|
public class CollisionTest : Script
|
||||||
|
{
|
||||||
|
public Collider collider { get; set; }
|
||||||
|
|
||||||
|
private bool printStay = false;
|
||||||
|
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
collider = GetComponent<Collider>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onCollisionEnter(info);
|
||||||
|
Debug.Log("Collision Enter");
|
||||||
|
|
||||||
|
printStay = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionStay(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onCollisionStay(info);
|
||||||
|
|
||||||
|
if (!printStay)
|
||||||
|
{
|
||||||
|
Debug.Log("Collision Stay");
|
||||||
|
printStay= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onCollisionExit(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onCollisionExit(info);
|
||||||
|
Debug.Log("Collision Exit");
|
||||||
|
|
||||||
|
printStay = false;
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: CollisionTest
|
||||||
|
ID: 163810535
|
||||||
|
Type: 9
|
|
@ -6,6 +6,7 @@ using static Item;
|
||||||
|
|
||||||
public class PhysicsTestObj : Script
|
public class PhysicsTestObj : Script
|
||||||
{
|
{
|
||||||
|
public Transform tf { get; set; }
|
||||||
public RigidBody body { get; set; }
|
public RigidBody body { get; set; }
|
||||||
public Collider collider { get; set; }
|
public Collider collider { get; set; }
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ public class PhysicsTestObj : Script
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
tf = GetComponent<Transform>();
|
||||||
body = GetComponent<RigidBody>();
|
body = GetComponent<RigidBody>();
|
||||||
collider = GetComponent<Collider>();
|
collider = GetComponent<Collider>();
|
||||||
|
|
||||||
|
@ -80,9 +82,12 @@ public class PhysicsTestObj : Script
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
Ray colliderRay = new Ray();
|
GameObject? target = GameObject.Find("Target");
|
||||||
colliderRay.Direction = Vector3.Right;
|
if (target.HasValue)
|
||||||
Physics.ColliderRaycast(collider.Owner, colliderRay, false, (ushort)64);
|
{
|
||||||
|
Physics.ColliderLineCast(collider.Owner, Vector3.Zero, target.Value.GetComponent<Transform>().GlobalPosition, false, (ushort)64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; ++i)
|
for (int i = 0; i < 6; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using SHADE;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using static Item;
|
||||||
|
|
||||||
|
|
||||||
|
public class TriggerTest : Script
|
||||||
|
{
|
||||||
|
public Collider collider { get; set; }
|
||||||
|
|
||||||
|
protected override void awake()
|
||||||
|
{
|
||||||
|
collider = GetComponent<Collider>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onTriggerEnter(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onTriggerEnter(info);
|
||||||
|
Debug.Log("Trigger Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onTriggerStay(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onTriggerStay(info);
|
||||||
|
Debug.Log("Trigger Stay");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void onTriggerExit(CollisionInfo info)
|
||||||
|
{
|
||||||
|
base.onTriggerExit(info);
|
||||||
|
Debug.Log("Trigger Exit");
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
Name: TriggerTest
|
||||||
|
ID: 159344038
|
||||||
|
Type: 9
|
|
@ -18,6 +18,7 @@
|
||||||
#include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h"
|
#include "Graphics/MiddleEnd/Interface/SHDebugDrawSystem.h"
|
||||||
#include "Math/Transform/SHTransformComponent.h"
|
#include "Math/Transform/SHTransformComponent.h"
|
||||||
#include "Physics/System/SHPhysicsSystem.h"
|
#include "Physics/System/SHPhysicsSystem.h"
|
||||||
|
#include "Scene/SHSceneManager.h"
|
||||||
#include "Tools/Utilities/SHUtilities.h"
|
#include "Tools/Utilities/SHUtilities.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
|
@ -53,12 +54,19 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
const auto& COLLIDER_COMPONENT_DENSE = SHComponentManager::GetDense<SHColliderComponent>();
|
const auto& COLLIDER_COMPONENT_DENSE = SHComponentManager::GetDense<SHColliderComponent>();
|
||||||
for (const auto& COLLIDER_COMPONENT : COLLIDER_COMPONENT_DENSE)
|
for (const auto& COLLIDER_COMPONENT : COLLIDER_COMPONENT_DENSE)
|
||||||
drawCollider(debugDrawSystem, COLLIDER_COMPONENT);
|
{
|
||||||
|
if (SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(COLLIDER_COMPONENT.GetEID()))
|
||||||
|
drawCollider(debugDrawSystem, COLLIDER_COMPONENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!physicsDebugDrawSystem->collidersToDraw.empty())
|
else if (!physicsDebugDrawSystem->collidersToDraw.empty())
|
||||||
{
|
{
|
||||||
for (const auto EID : physicsDebugDrawSystem->collidersToDraw)
|
for (const auto EID : physicsDebugDrawSystem->collidersToDraw)
|
||||||
drawCollider(debugDrawSystem, *SHComponentManager::GetComponent<SHColliderComponent>(EID));
|
{
|
||||||
|
if (SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(EID))
|
||||||
|
drawCollider(debugDrawSystem, *SHComponentManager::GetComponent<SHColliderComponent>(EID));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* physicsSystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
auto* physicsSystem = SHSystemManager::GetSystem<SHPhysicsSystem>();
|
||||||
|
|
|
@ -105,16 +105,14 @@ namespace SHADE
|
||||||
* TODO: Test if the scene graph transforms abides by setting world position. Collisions will ignore the scene graph hierarchy.
|
* TODO: Test if the scene graph transforms abides by setting world position. Collisions will ignore the scene graph hierarchy.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since this function never runs when editor in not in play, execute the function anyway
|
|
||||||
physicsSystem->collisionListener.CleanContainers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Collision & Trigger messages
|
// Collision & Trigger messages
|
||||||
if (scriptingSystem != nullptr)
|
if (scriptingSystem != nullptr)
|
||||||
scriptingSystem->ExecuteCollisionFunctions();
|
scriptingSystem->ExecuteCollisionFunctions();
|
||||||
|
|
||||||
|
// Since this function never runs when editor in not in play, execute the function anyway
|
||||||
|
physicsSystem->collisionListener.CleanContainers();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace SHADE
|
} // namespace SHADE
|
|
@ -0,0 +1,85 @@
|
||||||
|
/****************************************************************************************
|
||||||
|
* \file CollisionTags.hxx
|
||||||
|
* \author Diren D Bharwani, diren.dbharwani, 390002520
|
||||||
|
* \brief Interface for the managed Collision Tag Matrix & Collision Tag classes.
|
||||||
|
*
|
||||||
|
* \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or
|
||||||
|
* disclosure of this file or its contents without the prior written consent
|
||||||
|
* of DigiPen Institute of Technology is prohibited.
|
||||||
|
****************************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Project Includes
|
||||||
|
#include "Math/Ray.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
/* Type Definitions */
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collision tag.
|
||||||
|
/// </summary>
|
||||||
|
public ref struct CollisionTag sealed
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the object that this Entity represents.
|
||||||
|
/// </summary>
|
||||||
|
property System::String^ Name
|
||||||
|
{
|
||||||
|
System::String^ get();
|
||||||
|
void set(System::String^ value);
|
||||||
|
}
|
||||||
|
property unsigned short Mask
|
||||||
|
{
|
||||||
|
unsigned short get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Property Functions */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the state of a layer on the mask.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="layer">The layer to check.</param>
|
||||||
|
/// <returns>True if the state is active.</returns>
|
||||||
|
bool GetLayerState (int layer);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the state of a layer on the mask.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="layer">The layer to set.</param>
|
||||||
|
/// <param name="state">The state of the layer to set.</param>
|
||||||
|
void SetLayerState (int layer, bool state);
|
||||||
|
};
|
||||||
|
|
||||||
|
public ref class CollisionTagMatrix abstract sealed
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Member Functions */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the name of a Collision Tag
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagIndex">
|
||||||
|
/// The index of the tag in the matrix.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The name of the collision tag.</returns>
|
||||||
|
System::String^ GetTagName(int tagIndex);
|
||||||
|
|
||||||
|
|
||||||
|
int GetTagIndex(System::String^ tagName);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue