This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CQuadTree::Split(QTNode* pNode) | |
{ | |
// Children already exist? This shouldn't happen. | |
if(pNode->pChildren != nullptr) | |
{ | |
// Delete the actual nodes. | |
for(size_t i = 0; i < 4; ++i) delete pNode->pChildren[i]; | |
// Then delete the pointer array to the nodes. | |
delete[] pNode->pChildren; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The one used by the public, all it does is start | |
// the recursive algorithm with the root. | |
bool CQuadTree::Insert(CEntity* pEnt) | |
{ | |
// If inserted, we want to add to the whole internal list of | |
// objects, which is used later in CQuadTree::Update(). | |
if(this->RInsert(pBody, &m_Root)) | |
{ | |
mp_allBodies.push_back(pBody); | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool CQuadTree::RRemove(CEntity* pEnt, QTNode* pStart) | |
{ | |
// Leaf node? | |
if(pStart->pChildren == nullptr) | |
{ | |
// Iterate over the entities and remove a match (if any). | |
for(auto i : pStart->nodeObjects) | |
{ | |
// Is this the object we are looking for? | |
if(*i == pEnt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CEntity* CQuadTree::RCollides(const CEnity* pBody, | |
const QTNode* pStart) const | |
{ | |
// Is leaf? | |
if(pStart->pChildren == nullptr) | |
{ | |
// Iterate over each object in the node and check for | |
// collision. We also compare the objects to make sure | |
// we don't count a collision of an object with itself, | |
// which would obviously make no sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CQuadTree::Update() | |
{ | |
// Iterate over every object in the tree. | |
// This is why we stored them locally in Insert() | |
for(size_t i = 0; i < mp_allBodies.size(); ++i) | |
{ | |
// Object has moved. | |
if(mp_allBodies[i]->needs_update) | |
{ | |
// Remove the reference to the object from its current node. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "IronClad/Math/Math.hpp" | |
#include "IronClad/Entity/RigidBody.hpp" | |
using ic::math; | |
using ic::obj; | |
// Splits level into accessible 32x32 rectangles. | |
std::vector<rect_t> partition(const ic::CLevel& Level) | |
{ | |
const std::vector<CRigidBody*>& allEntities = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/timeb.h> | |
#include "IronClad.hpp" | |
using namespace ic; | |
// For tracking time. | |
uint32_t now() | |
{ | |
timeb t; | |
ftime(&t); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <ostream> | |
// This is in a different header, but we include it here | |
// for completeness-sake. | |
namespace math | |
{ | |
static inline | |
bool compf(const float a, const float b, | |
const float threshold = 0.0001) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Option.hpp" | |
COption::COption(){} | |
COption::COption(const string_t& value) : | |
m_value(value) {} | |
COption::COption(const COption& Opt) : | |
m_value(Opt.m_value) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the CSettings.hpp class definition: | |
std::map< | |
#ifndef _DEBUG | |
uint32_t, | |
#else | |
string_t, | |
#endif // _DEBUG | |
COption> m_Options; | |
COption& CSettings::operator[](const string_t& opt) |