mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
clean up a few stray bits
This commit is contained in:
parent
a609917cee
commit
b864908efd
1 changed files with 6 additions and 8 deletions
|
|
@ -301,9 +301,6 @@ void AINavigation::flock()
|
||||||
AIControllerData::Flocking flockingData = getCtrl()->mControllerData->mFlocking;
|
AIControllerData::Flocking flockingData = getCtrl()->mControllerData->mFlocking;
|
||||||
SimObjectPtr<SceneObject> obj = getCtrl()->getAIInfo()->mObj;
|
SimObjectPtr<SceneObject> obj = getCtrl()->getAIInfo()->mObj;
|
||||||
|
|
||||||
if (mRandI(0,100) > flockingData.mChance)
|
|
||||||
return;
|
|
||||||
|
|
||||||
obj->disableCollision();
|
obj->disableCollision();
|
||||||
Point3F pos = obj->getBoxCenter();
|
Point3F pos = obj->getBoxCenter();
|
||||||
Point3F searchArea = Point3F(flockingData.mMin / 2, flockingData.mMax / 2, getCtrl()->getAIInfo()->mObj->getObjBox().maxExtents.z / 2);
|
Point3F searchArea = Point3F(flockingData.mMin / 2, flockingData.mMax / 2, getCtrl()->getAIInfo()->mObj->getObjBox().maxExtents.z / 2);
|
||||||
|
|
@ -349,7 +346,8 @@ void AINavigation::flock()
|
||||||
Point3F objectCenter = other->getBoxCenter();
|
Point3F objectCenter = other->getBoxCenter();
|
||||||
|
|
||||||
F32 sumRad = flockingData.mMin + other->getAIController()->mControllerData->mFlocking.mMin;
|
F32 sumRad = flockingData.mMin + other->getAIController()->mControllerData->mFlocking.mMin;
|
||||||
sumRad += getCtrl()->getAIInfo()->mRadius + other->getAIController()->getAIInfo()->mRadius;
|
F32 separation = getCtrl()->getAIInfo()->mRadius + other->getAIController()->getAIInfo()->mRadius;
|
||||||
|
sumRad += separation;
|
||||||
|
|
||||||
Point3F offset = (pos - objectCenter);
|
Point3F offset = (pos - objectCenter);
|
||||||
F32 offsetLensq = offset.lenSquared(); //square roots are expensive, so use squared val compares
|
F32 offsetLensq = offset.lenSquared(); //square roots are expensive, so use squared val compares
|
||||||
|
|
@ -360,7 +358,7 @@ void AINavigation::flock()
|
||||||
{
|
{
|
||||||
found++;
|
found++;
|
||||||
offset.normalizeSafe();
|
offset.normalizeSafe();
|
||||||
offset *= sumRad;
|
offset *= sumRad + separation;
|
||||||
avoidanceOffset += offset; //accumulate total group, move away from that
|
avoidanceOffset += offset; //accumulate total group, move away from that
|
||||||
}
|
}
|
||||||
other->enableCollision();
|
other->enableCollision();
|
||||||
|
|
@ -375,7 +373,8 @@ void AINavigation::flock()
|
||||||
Point3F objectCenter = other->getBoxCenter();
|
Point3F objectCenter = other->getBoxCenter();
|
||||||
|
|
||||||
F32 sumRad = flockingData.mMin + other->getAIController()->mControllerData->mFlocking.mMin;
|
F32 sumRad = flockingData.mMin + other->getAIController()->mControllerData->mFlocking.mMin;
|
||||||
sumRad += getCtrl()->getAIInfo()->mRadius + other->getAIController()->getAIInfo()->mRadius;
|
F32 separation = getCtrl()->getAIInfo()->mRadius + other->getAIController()->getAIInfo()->mRadius;
|
||||||
|
sumRad += separation;
|
||||||
|
|
||||||
Point3F offset = (pos - objectCenter);
|
Point3F offset = (pos - objectCenter);
|
||||||
if ((flockingData.mMin > 0) && ((sumRad * sumRad) < (maxFlocksq)))
|
if ((flockingData.mMin > 0) && ((sumRad * sumRad) < (maxFlocksq)))
|
||||||
|
|
@ -385,7 +384,7 @@ void AINavigation::flock()
|
||||||
{
|
{
|
||||||
found++;
|
found++;
|
||||||
offset.normalizeSafe();
|
offset.normalizeSafe();
|
||||||
offset *= sumRad;
|
offset *= sumRad + separation;
|
||||||
avoidanceOffset -= offset; // subtract total group, move toward it
|
avoidanceOffset -= offset; // subtract total group, move toward it
|
||||||
}
|
}
|
||||||
other->enableCollision();
|
other->enableCollision();
|
||||||
|
|
@ -398,7 +397,6 @@ void AINavigation::flock()
|
||||||
avoidanceOffset.y = (mRandF() * avoidanceOffset.y) * 0.5 + avoidanceOffset.y * 0.75;
|
avoidanceOffset.y = (mRandF() * avoidanceOffset.y) * 0.5 + avoidanceOffset.y * 0.75;
|
||||||
if (avoidanceOffset.lenSquared() < (maxFlocksq))
|
if (avoidanceOffset.lenSquared() < (maxFlocksq))
|
||||||
{
|
{
|
||||||
avoidanceOffset.normalizeSafe();
|
|
||||||
dest += avoidanceOffset;
|
dest += avoidanceOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue