format codebase

This commit is contained in:
aronwk-aaron
2022-07-28 08:39:57 -05:00
parent 4f7aa11067
commit 19e77a38d8
881 changed files with 34700 additions and 38689 deletions

View File

@@ -16,4 +16,4 @@ public:
protected:
Singleton() = default;
};
};

View File

@@ -54,7 +54,7 @@ bool dpCollisionChecks::CheckBoxes(dpEntity* a, dpEntity* b) {
/*//Check if we're overlapping on X/Z:
if ((boxA->GetMaxWidth() >= boxB->GetMinWidth()) && //If our max width is greater than starting X of b
(boxA->GetMinWidth() <= boxB->GetMaxWidth()) && //If our start x is less than b's max width
(boxA->GetMaxDepth() >= boxB->GetMinDepth()) &&
(boxA->GetMaxDepth() >= boxB->GetMinDepth()) &&
(boxA->GetMinDepth() <= boxB->GetMaxDepth())) {
//Check if we're in the right height
@@ -93,8 +93,7 @@ bool dpCollisionChecks::CheckSphereBox(dpEntity* a, dpEntity* b) {
sphere = static_cast<dpShapeSphere*>(b->GetShape());
boxPos = a->GetPosition();
spherePos = b->GetPosition();
}
else {
} else {
box = static_cast<dpShapeBox*>(b->GetShape());
sphere = static_cast<dpShapeSphere*>(a->GetShape());
boxPos = b->GetPosition();
@@ -110,8 +109,8 @@ bool dpCollisionChecks::CheckSphereBox(dpEntity* a, dpEntity* b) {
float dX = x - spherePos.x;
float dY = y - spherePos.y;
float dZ = z - spherePos.z;
float distanceSquared = (dX * dX) + (dY * dY) + (dZ * dZ);
float distanceSquared = (dX * dX) + (dY * dY) + (dZ * dZ);
const float radius = sphere->GetRadius();
return distanceSquared < radius * radius;
return distanceSquared < radius* radius;
}

View File

@@ -9,4 +9,4 @@ namespace dpCollisionChecks {
bool CheckBoxes(dpEntity* a, dpEntity* b);
bool CheckSphereBox(dpEntity* a, dpEntity* b);
};
};

View File

@@ -8,9 +8,9 @@
enum eCollisionGroup : uint8_t
{
COLLISION_GROUP_ALL = 0 << 0,
COLLISION_GROUP_NEUTRAL = 1 << 0,
COLLISION_GROUP_FRIENDLY = 1 << 1,
COLLISION_GROUP_ENEMY = 1 << 2,
COLLISION_GROUP_DYNAMIC = 1 << 3,
COLLISION_GROUP_ALL = 0 << 0,
COLLISION_GROUP_NEUTRAL = 1 << 0,
COLLISION_GROUP_FRIENDLY = 1 << 1,
COLLISION_GROUP_ENEMY = 1 << 2,
COLLISION_GROUP_DYNAMIC = 1 << 3,
};

View File

@@ -4,4 +4,4 @@ enum class dpShapeType : unsigned short {
Invalid = 0,
Sphere,
Box
};
};

View File

@@ -89,8 +89,7 @@ void dpEntity::CheckCollision(dpEntity* other) {
//if (m_CollisionShape->GetShapeType() == dpShapeType::Sphere && other->GetShape()->GetShapeType() == dpShapeType::Sphere)
//std::cout << "started sphere col at: " << other->GetPosition().x << ", " << other->GetPosition().y << ", " << other->GetPosition().z << std::endl;
}
else if (!isColliding && wasFound) {
} else if (!isColliding && wasFound) {
m_CurrentlyCollidingObjects.erase(other->GetObjectID());
m_RemovedObjects.push_back(other);

View File

@@ -83,4 +83,4 @@ private:
std::vector<dpEntity*> m_NewObjects;
std::vector<dpEntity*> m_RemovedObjects;
std::map<LWOOBJID, dpEntity*> m_CurrentlyCollidingObjects;
};
};

View File

@@ -9,26 +9,26 @@ class dpEntity;
class dpGrid {
public:
//LU has a chunk size of 64x64, with each chunk unit being 3.2 ingame units.
int NUM_CELLS = 12; //Most worlds consist of 10 or 11 chunks, so I'm picking 12 to be safe.
int CELL_SIZE = 205; //64 * 3.2 = 204.8 rounded up
//LU has a chunk size of 64x64, with each chunk unit being 3.2 ingame units.
int NUM_CELLS = 12; //Most worlds consist of 10 or 11 chunks, so I'm picking 12 to be safe.
int CELL_SIZE = 205; //64 * 3.2 = 204.8 rounded up
public:
dpGrid(int numCells, int cellSize);
~dpGrid();
dpGrid(int numCells, int cellSize);
~dpGrid();
void Add(dpEntity* entity);
void Move(dpEntity* entity, float x, float z);
void Delete(dpEntity* entity);
void Add(dpEntity* entity);
void Move(dpEntity* entity, float x, float z);
void Delete(dpEntity* entity);
void Update(float deltaTime);
void Update(float deltaTime);
private:
void HandleEntity(dpEntity* entity, dpEntity* other);
void HandleCell(int x, int z, float deltaTime);
void HandleEntity(dpEntity* entity, dpEntity* other);
void HandleCell(int x, int z, float deltaTime);
private:
//cells on X, cells on Y for that X, then another vector that contains the entities within that cell.
std::vector<std::vector<std::forward_list<dpEntity*>>> m_Cells;
std::map<LWOOBJID, dpEntity*> m_GargantuanObjects;
//cells on X, cells on Y for that X, then another vector that contains the entities within that cell.
std::vector<std::vector<std::forward_list<dpEntity*>>> m_Cells;
std::map<LWOOBJID, dpEntity*> m_GargantuanObjects;
};

View File

@@ -3,8 +3,7 @@
#include <iostream>
dpShapeBase::dpShapeBase(dpEntity* parentEntity) :
m_ParentEntity(parentEntity)
{
m_ParentEntity(parentEntity) {
}
dpShapeBase::~dpShapeBase() {
@@ -14,4 +13,4 @@ bool dpShapeBase::IsColliding(dpShapeBase* other) {
std::cout << "Base shapes do not have any *shape* to them, and thus cannot be overlapping." << std::endl;
std::cout << "You should be using a shape class inherited from this base class." << std::endl;
return false;
}
}

View File

@@ -17,4 +17,4 @@ public:
protected:
dpEntity* m_ParentEntity;
dpShapeType m_ShapeType = dpShapeType::Invalid;
};
};

View File

@@ -11,11 +11,10 @@
dpShapeBox::dpShapeBox(dpEntity* parentEntity, float width, float height, float depth) :
dpShapeBase(parentEntity),
m_Width(width/2),
m_Height(height/2),
m_Depth(depth/2),
m_Scale(1.0f)
{
m_Width(width / 2),
m_Height(height / 2),
m_Depth(depth / 2),
m_Scale(1.0f) {
m_ShapeType = dpShapeType::Box;
InitVertices();

View File

@@ -69,4 +69,4 @@ private:
bool isTransformed = false;
void InsertVertices();
};
};

View File

@@ -4,8 +4,7 @@
dpShapeSphere::dpShapeSphere(dpEntity* parentEntity, float radius) :
dpShapeBase(parentEntity),
m_Radius(radius)
{
m_Radius(radius) {
m_ShapeType = dpShapeType::Sphere;
}

View File

@@ -14,4 +14,4 @@ public:
private:
float m_Radius;
};
};

View File

@@ -77,8 +77,7 @@ void dpWorld::RemoveEntity(dpEntity* entity) {
if (m_Grid) {
m_Grid->Delete(entity);
}
else {
} else {
if (entity->GetIsStatic()) {
for (size_t i = 0; i < m_StaticEntities.size(); ++i) {
if (m_StaticEntities[i] == entity) {
@@ -87,8 +86,7 @@ void dpWorld::RemoveEntity(dpEntity* entity) {
break;
}
}
}
else {
} else {
for (size_t i = 0; i < m_DynamicEntites.size(); ++i) {
if (m_DynamicEntites[i] == entity) {
delete m_DynamicEntites[i];
@@ -127,8 +125,7 @@ bool dpWorld::LoadNavmeshByZoneID(unsigned int zoneID) {
std::string path = "./res/maps/navmeshes/" + std::to_string(zoneID) + ".bin";
m_navMesh = LoadNavmesh(path.c_str());
if (m_navMesh) { m_navQuery = dtAllocNavMeshQuery(); m_navQuery->init(m_navMesh, 2048); }
else return false;
if (m_navMesh) { m_navQuery = dtAllocNavMeshQuery(); m_navQuery->init(m_navMesh, 2048); } else return false;
return true;
}
@@ -136,14 +133,14 @@ bool dpWorld::LoadNavmeshByZoneID(unsigned int zoneID) {
dtNavMesh* dpWorld::LoadNavmesh(const char* path) {
FILE* fp;
#ifdef _WIN32
fopen_s(&fp, path, "rb");
#elif __APPLE__
// macOS has 64bit file IO by default
fp = fopen(path, "rb");
#else
fp = fopen64(path, "rb");
#endif
#ifdef _WIN32
fopen_s(&fp, path, "rb");
#elif __APPLE__
// macOS has 64bit file IO by default
fp = fopen(path, "rb");
#else
fp = fopen64(path, "rb");
#endif
if (!fp) {
return 0;
@@ -347,8 +344,7 @@ std::vector<NiPoint3> dpWorld::GetPath(const NiPoint3& startPos, const NiPoint3&
path.push_back(newPoint);
}
}
}
else {
} else {
m_npolys = 0;
m_nstraightPath = 0;
}

View File

@@ -77,4 +77,4 @@ private:
class dtNavMeshQuery* m_navQuery;
unsigned char m_navMeshDrawFlags;
rcContext* m_ctx;
};
};

View File

@@ -32,4 +32,4 @@ int main() {
}
return 0;
}*/
}*/