Bug fixes and scene changes #267

Merged
glencelow merged 15 commits from PlayerController into main 2022-11-23 20:53:44 +08:00
7 changed files with 39 additions and 21 deletions
Showing only changes of commit 64d521a651 - Show all commits

View File

@ -178,14 +178,23 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHBox::TestPoint(const SHVec3& point) noexcept
bool SHBox::TestPoint(const SHVec3& point) const noexcept
{
return BoundingBox::Contains(point);
}
bool SHBox::Raycast(const SHRay& ray, float& distance) noexcept
SHRaycastResult SHBox::Raycast(const SHRay& ray) const noexcept
{
return BoundingBox::Intersects(ray.position, ray.direction, distance);
SHRaycastResult result;
result.hit = Intersects(ray.position, ray.direction, result.distance);
if (result.hit)
{
result.position = ray.position + ray.direction * result.distance;
result.angle = SHVec3::Angle(ray.position, result.position);
}
return result;
}
bool SHBox::Contains(const SHBox& rhs) const noexcept

View File

@ -76,8 +76,8 @@ namespace SHADE
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] bool TestPoint (const SHVec3& point) noexcept override;
[[nodiscard]] bool Raycast (const SHRay& ray, float& distance) noexcept override;
[[nodiscard]] bool TestPoint (const SHVec3& point) const noexcept override;
[[nodiscard]] SHRaycastResult Raycast(const SHRay& ray) const noexcept override;
[[nodiscard]] bool Contains (const SHBox& rhs) const noexcept;
[[nodiscard]] float Volume () const noexcept;

View File

@ -69,8 +69,8 @@ namespace SHADE
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] virtual bool TestPoint (const SHVec3& point) noexcept = 0;
[[nodiscard]] virtual bool Raycast (const SHRay& ray, float& distance) noexcept = 0;
[[nodiscard]] virtual bool TestPoint (const SHVec3& point) const noexcept = 0;
[[nodiscard]] virtual SHRaycastResult Raycast (const SHRay& ray) const noexcept = 0;
protected:
/*---------------------------------------------------------------------------------*/

View File

@ -138,14 +138,23 @@ namespace SHADE
/* Public Function Member Definitions */
/*-----------------------------------------------------------------------------------*/
bool SHSphere::TestPoint(const SHVec3& point) noexcept
bool SHSphere::TestPoint(const SHVec3& point) const noexcept
{
return BoundingSphere::Contains(point);
}
bool SHSphere::Raycast(const SHRay& ray, float& distance) noexcept
SHRaycastResult SHSphere::Raycast(const SHRay& ray) const noexcept
{
return Intersects(ray.position, ray.direction, distance);
SHRaycastResult result;
result.hit = Intersects(ray.position, ray.direction, result.distance);
if (result.hit)
{
result.position = ray.position + ray.direction * result.distance;
result.angle = SHVec3::Angle(ray.position, result.position);
}
return result;
}
bool SHSphere::Contains(const SHSphere& rhs) const noexcept

View File

@ -64,12 +64,12 @@ namespace SHADE
/* Function Members */
/*---------------------------------------------------------------------------------*/
[[nodiscard]] bool TestPoint (const SHVec3& point) noexcept override;
[[nodiscard]] bool Raycast (const SHRay& ray, float& distance) noexcept override;
[[nodiscard]] bool TestPoint (const SHVec3& point) const noexcept override;
[[nodiscard]] SHRaycastResult Raycast(const SHRay& ray) const noexcept override;
[[nodiscard]] bool Contains (const SHSphere& rhs) const noexcept;
[[nodiscard]] float Volume () const noexcept;
[[nodiscard]] float SurfaceArea () const noexcept;
[[nodiscard]] bool Contains (const SHSphere& rhs) const noexcept;
[[nodiscard]] float Volume () const noexcept;
[[nodiscard]] float SurfaceArea () const noexcept;
/*---------------------------------------------------------------------------------*/

View File

@ -265,11 +265,11 @@ namespace SHADE
return;
}
const int NUM_SHAPES = static_cast<int>(componentGroup.colliderComponent->GetCollisionShapes().size());
for (int i = 0; i < NUM_SHAPES; ++i)
physicsObject->AddCollisionShape(i);
//const int NUM_SHAPES = static_cast<int>(componentGroup.colliderComponent->GetCollisionShapes().size());
//for (int i = 0; i < NUM_SHAPES; ++i)
// physicsObject->AddCollisionShape(i);
physicsObject->SyncColliders(*componentGroup.colliderComponent);
//physicsObject->SyncColliders(*componentGroup.colliderComponent);
}
void SHPhysicsObjectManager::removeRigidBody(const QueueCommand&, SHPhysicsObject* physicsObject, const PhysicsComponentGroup& componentGroup)

View File

@ -168,7 +168,7 @@ namespace SHADE
}
bool BoxCollider::Raycast(Ray ray, float maxDistance)
{
return getNativeCollisionShape<SHBox>().Raycast(Convert::ToNative(ray), maxDistance);
return getNativeCollisionShape<SHBox>().Raycast(Convert::ToNative(ray));
}
/*---------------------------------------------------------------------------------*/
@ -200,7 +200,7 @@ namespace SHADE
}
bool SphereCollider::Raycast(Ray ray, float maxDistance)
{
return getNativeCollisionShape<SHBox>().Raycast(Convert::ToNative(ray), maxDistance);
return getNativeCollisionShape<SHBox>().Raycast(Convert::ToNative(ray));
}
/*---------------------------------------------------------------------------------*/