Refactored Raycasting, Added Layers for Raycasting to C#, Fixed Collision Tag Panel #331
|
@ -4,14 +4,14 @@
|
|||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0, y: 7, z: 0}
|
||||
Translate: {x: 0, y: 7, z: -0.5}
|
||||
Rotate: {x: 0, y: 0, z: 0.785398185}
|
||||
Scale: {x: 0.999999344, y: 0.999999821, z: 0.999999523}
|
||||
IsActive: true
|
||||
RigidBody Component:
|
||||
Type: Dynamic
|
||||
Drag: 0.00999999978
|
||||
Angular Drag: 0
|
||||
Angular Drag: 0.100000001
|
||||
Use Gravity: true
|
||||
Interpolate: true
|
||||
Sleeping Enabled: true
|
||||
|
@ -34,11 +34,7 @@
|
|||
Position Offset: {x: 0, y: 0, z: 0}
|
||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||
IsActive: true
|
||||
Scripts:
|
||||
- Type: PhysicsTestObj
|
||||
Enabled: true
|
||||
forceAmount: 200
|
||||
torqueAmount: 5
|
||||
Scripts: ~
|
||||
- EID: 1
|
||||
Name: Default
|
||||
IsActive: true
|
||||
|
@ -70,7 +66,7 @@
|
|||
Camera Component:
|
||||
Position: {x: 0, y: 2, z: 7}
|
||||
Pitch: 0
|
||||
Yaw: 95
|
||||
Yaw: 0
|
||||
Roll: 0
|
||||
Width: 1920
|
||||
Height: 1080
|
||||
|
@ -182,9 +178,9 @@
|
|||
Scale: {x: 1, y: 1, z: 1}
|
||||
IsActive: true
|
||||
RigidBody Component:
|
||||
Type: Static
|
||||
Type: Dynamic
|
||||
Drag: 0.00999999978
|
||||
Angular Drag: 0.00999999978
|
||||
Angular Drag: 0.100000001
|
||||
Use Gravity: true
|
||||
Interpolate: true
|
||||
Sleeping Enabled: true
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0, y: 0, z: 0}
|
||||
Translate: {x: 2, y: 0, z: 0}
|
||||
Rotate: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 1, y: 1, z: 1}
|
||||
IsActive: true
|
||||
|
@ -12,7 +12,7 @@
|
|||
Type: Dynamic
|
||||
Drag: 0.00999999978
|
||||
Angular Drag: 0.100000001
|
||||
Use Gravity: false
|
||||
Use Gravity: true
|
||||
Interpolate: true
|
||||
Sleeping Enabled: false
|
||||
Freeze Position X: false
|
||||
|
@ -41,7 +41,7 @@
|
|||
NumberOfChildren: 0
|
||||
Components:
|
||||
Camera Component:
|
||||
Position: {x: 0, y: 0, z: -10}
|
||||
Position: {x: 0, y: 0, z: 5}
|
||||
Pitch: 0
|
||||
Yaw: 0
|
||||
Roll: 0
|
||||
|
@ -51,4 +51,50 @@
|
|||
Far: 10000
|
||||
Perspective: true
|
||||
IsActive: true
|
||||
Scripts: ~
|
||||
- EID: 2
|
||||
Name: Default
|
||||
IsActive: true
|
||||
NumberOfChildren: 0
|
||||
Components:
|
||||
Transform Component:
|
||||
Translate: {x: 0, y: -3, 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.100000001
|
||||
Use Gravity: false
|
||||
Interpolate: true
|
||||
Sleeping Enabled: false
|
||||
Freeze Position X: true
|
||||
Freeze Position Y: true
|
||||
Freeze Position Z: true
|
||||
Freeze Rotation X: false
|
||||
Freeze Rotation Y: false
|
||||
Freeze Rotation Z: false
|
||||
IsActive: true
|
||||
Collider Component:
|
||||
Colliders:
|
||||
- Is Trigger: false
|
||||
Collision Tag: 1
|
||||
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}
|
||||
- Is Trigger: false
|
||||
Collision Tag: 1
|
||||
Type: Box
|
||||
Half Extents: {x: 1, y: 1, z: 1}
|
||||
Friction: 0.400000006
|
||||
Bounciness: 0
|
||||
Density: 1
|
||||
Position Offset: {x: 2, y: 0, z: 0}
|
||||
Rotation Offset: {x: 0, y: 0, z: 0}
|
||||
IsActive: true
|
||||
Scripts: ~
|
|
@ -97,6 +97,19 @@ namespace SHADE
|
|||
/* Public Member Function Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void SHBox::Update() noexcept
|
||||
{
|
||||
const SHTransform& PARENT_TRANSFORM = collider->GetTransform();
|
||||
SetScale(PARENT_TRANSFORM.scale);
|
||||
|
||||
if (rp3dCollider)
|
||||
{
|
||||
const rp3d::Transform OFFSETS{ positionOffset, SHQuaternion::FromEuler(rotationOffset) };
|
||||
rp3dCollider->setLocalToBodyTransform(OFFSETS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SHMatrix SHBox::GetTRS() const noexcept
|
||||
{
|
||||
const SHQuaternion ROTATION = collider->GetTransform().orientation * SHQuaternion::FromEuler(rotationOffset);
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace SHADE
|
|||
/* Function Members */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
void Update () noexcept override;
|
||||
[[nodiscard]] SHMatrix GetTRS () const noexcept override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace SHADE
|
|||
* @brief
|
||||
* Computes the transform of the shape.
|
||||
*/
|
||||
void Update() noexcept;
|
||||
virtual void Update() noexcept;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
|
|
@ -98,10 +98,25 @@ namespace SHADE
|
|||
/* Public Member Function Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void SHSphere::Update() noexcept
|
||||
{
|
||||
const SHTransform& PARENT_TRANSFORM = collider->GetTransform();
|
||||
|
||||
const float SPHERE_SCALE = std::fabs(SHMath::Max({ PARENT_TRANSFORM.scale.x, PARENT_TRANSFORM.scale.y, PARENT_TRANSFORM.scale.z }));
|
||||
SetScale(SPHERE_SCALE);
|
||||
|
||||
if (rp3dCollider)
|
||||
{
|
||||
const rp3d::Transform OFFSETS{ positionOffset, SHQuaternion::FromEuler(rotationOffset) };
|
||||
rp3dCollider->setLocalToBodyTransform(OFFSETS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SHMatrix SHSphere::GetTRS() const noexcept
|
||||
{
|
||||
const SHQuaternion ROTATION = collider->GetTransform().orientation * SHQuaternion::FromEuler(rotationOffset);
|
||||
const SHVec3 SCALE = GetWorldRadius() * 2.0f;
|
||||
const SHVec3 SCALE = GetWorldRadius();
|
||||
|
||||
const SHMatrix TRS = SHMatrix::Rotate(ROTATION) * SHMatrix::Translate(collider->GetTransform().position);
|
||||
const SHVec3 POSITION = SHVec3::Transform(positionOffset, TRS);
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace SHADE
|
|||
/* Function Members */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
void Update () noexcept override;
|
||||
[[nodiscard]] SHMatrix GetTRS () const noexcept override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,19 +33,6 @@ namespace SHADE
|
|||
, collisionBody { nullptr }
|
||||
{}
|
||||
|
||||
SHColliderComponent::~SHColliderComponent()
|
||||
{
|
||||
int32_t numShapes = static_cast<int32_t>(shapes.size());
|
||||
while (--numShapes >= 0)
|
||||
{
|
||||
delete shapes[numShapes];
|
||||
shapes[numShapes] = nullptr;
|
||||
}
|
||||
|
||||
shapes.clear();
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Getter Function Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -150,6 +137,18 @@ namespace SHADE
|
|||
/* Public Function Member Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void SHColliderComponent::OnDestroy()
|
||||
{
|
||||
int32_t numShapes = static_cast<int32_t>(shapes.size());
|
||||
while (--numShapes >= 0)
|
||||
{
|
||||
delete shapes[numShapes];
|
||||
shapes[numShapes] = nullptr;
|
||||
}
|
||||
|
||||
shapes.clear();
|
||||
}
|
||||
|
||||
const SHMatrix& SHColliderComponent::ComputeTRS() noexcept
|
||||
{
|
||||
return transform.ComputeTRS();
|
||||
|
@ -198,8 +197,6 @@ namespace SHADE
|
|||
|
||||
int SHColliderComponent::AddBoxCollisionShape(const SHVec3& relativeExtents, const SHVec3& posOffset, const SHVec3& rotOffset)
|
||||
{
|
||||
SHASSERT(factory, "Physics factory missing from Collider Component! Unable to add colliders!")
|
||||
|
||||
const uint32_t NEW_INDEX = static_cast<uint32_t>(shapes.size());
|
||||
|
||||
// Create collision shape
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace SHADE
|
|||
SHColliderComponent () noexcept;
|
||||
SHColliderComponent (const SHColliderComponent& rhs) noexcept = default;
|
||||
SHColliderComponent (SHColliderComponent&& rhs) noexcept = default;
|
||||
~SHColliderComponent () override;
|
||||
~SHColliderComponent () override = default;
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Operator Overloads */
|
||||
|
@ -101,6 +101,8 @@ namespace SHADE
|
|||
/* Function Members */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
void OnDestroy() override;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Computes the TRS for the collider's transform
|
||||
|
|
|
@ -155,21 +155,22 @@ namespace SHADE
|
|||
|
||||
type = newType;
|
||||
|
||||
SHASSERT(rigidBody, "Unable to find rp3dBody on RigidBodyComponent!")
|
||||
|
||||
switch (type)
|
||||
if (rigidBody)
|
||||
{
|
||||
case Type::STATIC:
|
||||
rigidBody->setType(rp3d::BodyType::STATIC);
|
||||
break;
|
||||
case Type::KINEMATIC:
|
||||
rigidBody->setType(rp3d::BodyType::KINEMATIC);
|
||||
break;
|
||||
case Type::DYNAMIC:
|
||||
rigidBody->setType(rp3d::BodyType::DYNAMIC);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (type)
|
||||
{
|
||||
case Type::STATIC:
|
||||
rigidBody->setType(rp3d::BodyType::STATIC);
|
||||
break;
|
||||
case Type::KINEMATIC:
|
||||
rigidBody->setType(rp3d::BodyType::KINEMATIC);
|
||||
break;
|
||||
case Type::DYNAMIC:
|
||||
rigidBody->setType(rp3d::BodyType::DYNAMIC);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,8 +158,8 @@ namespace SHADE
|
|||
, LINEAR_Y = 0x8
|
||||
, LINEAR_Z = 0x10
|
||||
, ANGULAR_X = 0x20
|
||||
, ANGULAR_Y = 0x30
|
||||
, ANGULAR_Z = 0x40
|
||||
, ANGULAR_Y = 0x40
|
||||
, ANGULAR_Z = 0x80
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -134,6 +134,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
objectManager.SetFactory(&factory);
|
||||
collisionListener.BindToSystem(this);
|
||||
raycaster.BindToSystem(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue