refactor(Core/Misc): add braces and impove codestyle (#6402)

This commit is contained in:
Kargatum
2021-06-25 00:50:18 +07:00
committed by GitHub
parent 33c271cc7c
commit 3c24b511f2
72 changed files with 1486 additions and 401 deletions

View File

@@ -72,14 +72,18 @@ struct DynTreeImpl : public ParentTree
void update(uint32 difftime)
{
if (!size())
{
return;
}
rebalance_timer.Update(difftime);
if (rebalance_timer.Passed())
{
rebalance_timer.Reset(CHECK_TREE_PERIOD);
if (unbalanced_times > 0)
{
balance();
}
}
}
@@ -133,7 +137,9 @@ struct DynamicTreeIntersectionCallback
{
bool result = obj.intersectRay(r, distance, stopAtFirstHit, phase_mask);
if (result)
{
did_hit = result;
}
return result;
}
bool didHit() const { return did_hit;}
@@ -146,7 +152,9 @@ bool DynamicMapTree::getIntersectionTime(const uint32 phasemask, const G3D::Ray&
DynamicTreeIntersectionCallback callback(phasemask);
impl->intersectRay(ray, callback, distance, endPos, false);
if (callback.didHit())
{
maxDist = distance;
}
return callback.didHit();
}
@@ -173,12 +181,18 @@ bool DynamicMapTree::getObjectHitPos(const uint32 phasemask, const G3D::Vector3&
if (modifyDist < 0)
{
if ((resultHit - startPos).magnitude() > -modifyDist)
{
resultHit = resultHit + dir * modifyDist;
}
else
{
resultHit = startPos;
}
}
else
{
resultHit = resultHit + dir * modifyDist;
}
result = true;
}
@@ -197,7 +211,9 @@ bool DynamicMapTree::isInLineOfSight(float x1, float y1, float z1, float x2, flo
float maxDist = (v2 - v1).magnitude();
if (!G3D::fuzzyGt(maxDist, 0) )
{
return true;
}
G3D::Ray r(v1, (v2 - v1) / maxDist);
DynamicTreeIntersectionCallback callback(phasemask);
@@ -214,7 +230,11 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
impl->intersectZAllignedRay(r, callback, maxSearchDist);
if (callback.didHit())
{
return v.z - maxSearchDist;
}
else
{
return -G3D::finf();
}
}