Use better API terminology for radii

- SetProximityRadius just calls AddProximityRadius so its clear what is going on.
- created struct BoxDimensions for clear reading of what the floats are
This commit is contained in:
David Markowitz
2023-06-16 19:53:22 -07:00
parent be17d1a467
commit 68a5cc1d89
10 changed files with 48 additions and 35 deletions

View File

@@ -18,7 +18,7 @@ dpEntity::dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStati
break;
case dpShapeType::Box:
m_CollisionShape = new dpShapeBox(this, 1.0f, 1.0f, 1.0f);
m_CollisionShape = new dpShapeBox(this, BoxDimensions(1.0f, 1.0f, 1.0f));
break;
default:
@@ -26,14 +26,14 @@ dpEntity::dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStati
}
}
dpEntity::dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStatic) {
dpEntity::dpEntity(const LWOOBJID& objectID, const BoxDimensions& boxDimensions, bool isStatic) {
m_ObjectID = objectID;
m_IsStatic = isStatic;
m_CollisionShape = nullptr;
m_Scale = 1.0f;
m_CollisionGroup = COLLISION_GROUP_ALL;
m_CollisionShape = new dpShapeBox(this, boxDimensions.x, boxDimensions.y, boxDimensions.z);
m_CollisionShape = new dpShapeBox(this, boxDimensions);
}
dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic) {
@@ -43,7 +43,7 @@ dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float de
m_Scale = 1.0f;
m_CollisionGroup = COLLISION_GROUP_ALL;
m_CollisionShape = new dpShapeBox(this, width, height, depth);
m_CollisionShape = new dpShapeBox(this, BoxDimensions(width, height, depth));
}
dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) {

View File

@@ -10,12 +10,14 @@
#include "dpCollisionGroups.h"
#include "dpGrid.h"
class BoxDimensions;
class dpEntity {
friend class dpGrid; //using friend here for now so grid can access everything
public:
dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStatic = true);
dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStatic = true);
dpEntity(const LWOOBJID& objectID, const BoxDimensions& boxDimensions, bool isStatic = true);
dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic = true);
dpEntity(const LWOOBJID& objectID, float radius, bool isStatic = true);

View File

@@ -9,11 +9,11 @@
#include <iostream>
dpShapeBox::dpShapeBox(dpEntity* parentEntity, float width, float height, float depth) :
dpShapeBox::dpShapeBox(dpEntity* parentEntity, const BoxDimensions& dimensions) :
dpShapeBase(parentEntity),
m_Width(width / 2),
m_Height(height / 2),
m_Depth(depth / 2),
m_Width(dimensions.width / 2),
m_Height(dimensions.height / 2),
m_Depth(dimensions.depth / 2),
m_Scale(1.0f) {
m_ShapeType = dpShapeType::Box;

View File

@@ -4,9 +4,16 @@
#include "NiPoint3.h"
#include "NiQuaternion.h"
struct BoxDimensions {
BoxDimensions(float width, float height, float depth) : width(width), height(height), depth(depth) { }
float width;
float height;
float depth;
};
class dpShapeBox : public dpShapeBase {
public:
dpShapeBox(dpEntity* parentEntity, float width, float height, float depth);
dpShapeBox(dpEntity* parentEntity, const BoxDimensions& dimensions);
~dpShapeBox();
bool IsColliding(dpShapeBase* other);