mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 22:05:40 +00:00
TORQUE_NAVIGATION_ENABLED filtering
This commit is contained in:
parent
618ddbc9ba
commit
f278150185
4 changed files with 249 additions and 202 deletions
|
|
@ -110,8 +110,6 @@ void AIController::setAim(SimObjectPtr<SceneObject> objIn, F32 rad, Point3F offs
|
|||
mAimTarget->mAimOffset = offset;
|
||||
}
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
|
||||
bool AIController::getAIMove(Move* movePtr)
|
||||
{
|
||||
*movePtr = NullMove;
|
||||
|
|
@ -145,9 +143,9 @@ bool AIController::getAIMove(Move* movePtr)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
if (sbo->getDamageState() == ShapeBase::Enabled && getGoal())
|
||||
{
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
if (mMovement.mMoveState != ModeStop)
|
||||
getNav()->updateNavMesh();
|
||||
|
||||
|
|
@ -202,8 +200,39 @@ bool AIController::getAIMove(Move* movePtr)
|
|||
else getGoal()->mInFiringRange = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (getGoal()->getDist() > mControllerData->mMoveTolerance)
|
||||
{
|
||||
if (getGoal()->mPosSet)
|
||||
getNav()->setPathDestination(getGoal()->getPosition(true));
|
||||
|
||||
getGoal()->mInRange = false;
|
||||
}
|
||||
if (getGoal()->getDist() < mControllerData->mMoveTolerance)
|
||||
{
|
||||
mMovement.mMoveState = ModeStop;
|
||||
|
||||
if (!getGoal()->mInRange)
|
||||
{
|
||||
getGoal()->mInRange = true;
|
||||
throwCallback("onTargetInRange");
|
||||
}
|
||||
else getGoal()->mInRange = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getGoal()->getDist() < mControllerData->mAttackRadius)
|
||||
{
|
||||
if (!getGoal()->mInFiringRange)
|
||||
{
|
||||
getGoal()->mInFiringRange = true;
|
||||
throwCallback("onTargetInFiringRange");
|
||||
}
|
||||
}
|
||||
else getGoal()->mInFiringRange = false;
|
||||
}
|
||||
#endif // TORQUE_NAVIGATION_ENABLED
|
||||
}
|
||||
// Orient towards the aim point, aim object, or towards
|
||||
// our destination.
|
||||
if (getAim() || mMovement.mMoveState != ModeStop)
|
||||
|
|
@ -486,19 +515,20 @@ void AIControllerData::resolveStuck(AIController* obj)
|
|||
AIControllerData::AIControllerData()
|
||||
{
|
||||
mMoveTolerance = 0.25f;
|
||||
mFollowTolerance = 1.0f;
|
||||
mAttackRadius = 2.0f;
|
||||
mMoveStuckTolerance = 0.01f;
|
||||
mMoveStuckTestDelay = 30;
|
||||
mLinkTypes = LinkData(AllFlags);
|
||||
mNavSize = AINavigation::Regular;
|
||||
mHeightTolerance = 0.001f;
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
mFollowTolerance = 1.0f;
|
||||
mLinkTypes = LinkData(AllFlags);
|
||||
mNavSize = AINavigation::Regular;
|
||||
mFlocking.mChance = 90;
|
||||
mFlocking.mMin = 1.0f;
|
||||
mFlocking.mMax = 3.0f;
|
||||
mFlocking.mSideStep = 0.01f;
|
||||
|
||||
#endif
|
||||
resolveYawPtr.bind(this, &AIControllerData::resolveYaw);
|
||||
resolvePitchPtr.bind(this, &AIControllerData::resolvePitch);
|
||||
resolveRollPtr.bind(this, &AIControllerData::resolveRoll);
|
||||
|
|
@ -510,18 +540,20 @@ AIControllerData::AIControllerData()
|
|||
AIControllerData::AIControllerData(const AIControllerData& other, bool temp_clone) : SimDataBlock(other, temp_clone)
|
||||
{
|
||||
mMoveTolerance = other.mMoveTolerance;
|
||||
mFollowTolerance = other.mFollowTolerance;
|
||||
mAttackRadius = other.mAttackRadius;
|
||||
mMoveStuckTolerance = other.mMoveStuckTolerance;
|
||||
mMoveStuckTestDelay = other.mMoveStuckTestDelay;
|
||||
mLinkTypes = other.mLinkTypes;
|
||||
mNavSize = other.mNavSize;
|
||||
mHeightTolerance = other.mHeightTolerance;
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
mFollowTolerance = other.mFollowTolerance;
|
||||
mLinkTypes = other.mLinkTypes;
|
||||
mNavSize = other.mNavSize;
|
||||
mFlocking.mChance = other.mFlocking.mChance;
|
||||
mFlocking.mMin = other.mFlocking.mMin;
|
||||
mFlocking.mMax = other.mFlocking.mMax;
|
||||
mFlocking.mSideStep = other.mFlocking.mSideStep;
|
||||
#endif
|
||||
|
||||
resolveYawPtr.bind(this, &AIControllerData::resolveYaw);
|
||||
resolvePitchPtr.bind(this, &AIControllerData::resolvePitch);
|
||||
|
|
@ -543,12 +575,8 @@ void AIControllerData::initPersistFields()
|
|||
"it helps the AIController controlled object from never reaching its destination due to minor obstacles, "
|
||||
"rounding errors on its position calculation, etc. By default it is set to 0.25.\n");
|
||||
|
||||
addFieldV("followTolerance", TypeRangedF32, Offset(mFollowTolerance, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance from destination before stopping.\n\n"
|
||||
"When the AIController controlled object is moving to a given destination it will move to within "
|
||||
"this distance of the destination and then stop. By providing this tolerance "
|
||||
"it helps the AIController controlled object from never reaching its destination due to minor obstacles, "
|
||||
"rounding errors on its position calculation, etc. By default it is set to 0.25.\n");
|
||||
addFieldV("AttackRadius", TypeRangedF32, Offset(mAttackRadius, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance considered in firing range for callback purposes.");
|
||||
|
||||
addFieldV("moveStuckTolerance", TypeRangedF32, Offset(mMoveStuckTolerance, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance tolerance on stuck check.\n\n"
|
||||
|
|
@ -569,10 +597,16 @@ void AIControllerData::initPersistFields()
|
|||
"before the AIController controlled object starts to check if it is stuck. This delay allows the AIController controlled object "
|
||||
"to accelerate to full speed without its initial slow start being considered as stuck.\n"
|
||||
"@note Set to zero to have the stuck test start immediately.\n");
|
||||
endGroup("AI");
|
||||
|
||||
addFieldV("AttackRadius", TypeRangedF32, Offset(mAttackRadius, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance considered in firing range for callback purposes.");
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
addGroup("Pathfinding");
|
||||
addFieldV("followTolerance", TypeRangedF32, Offset(mFollowTolerance, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance from destination before stopping.\n\n"
|
||||
"When the AIController controlled object is moving to a given destination it will move to within "
|
||||
"this distance of the destination and then stop. By providing this tolerance "
|
||||
"it helps the AIController controlled object from never reaching its destination due to minor obstacles, "
|
||||
"rounding errors on its position calculation, etc. By default it is set to 0.25.\n");
|
||||
addFieldV("FlockChance", TypeRangedS32, Offset(mFlocking.mChance, AIControllerData), &CommonValidators::S32Percent,
|
||||
"@brief chance of flocking.");
|
||||
addFieldV("FlockMin", TypeRangedF32, Offset(mFlocking.mMin, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
|
|
@ -581,10 +615,6 @@ void AIControllerData::initPersistFields()
|
|||
"@brief max flocking clustering distance.");
|
||||
addFieldV("FlockSideStep", TypeRangedF32, Offset(mFlocking.mSideStep, AIControllerData), &CommonValidators::PositiveFloat,
|
||||
"@brief Distance from destination before we stop moving out of the way.");
|
||||
endGroup("AI");
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
addGroup("Pathfinding");
|
||||
|
||||
addField("allowWalk", TypeBool, Offset(mLinkTypes.walk, AIControllerData),
|
||||
"Allow the character to walk on dry land.");
|
||||
|
|
@ -611,19 +641,21 @@ void AIControllerData::packData(BitStream* stream)
|
|||
{
|
||||
Parent::packData(stream);
|
||||
stream->write(mMoveTolerance);
|
||||
stream->write(mFollowTolerance);
|
||||
stream->write(mAttackRadius);
|
||||
stream->write(mMoveStuckTolerance);
|
||||
stream->write(mMoveStuckTestDelay);
|
||||
stream->write(mHeightTolerance);
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
stream->write(mFollowTolerance);
|
||||
//enums
|
||||
stream->write(mLinkTypes.getFlags());
|
||||
stream->write((U32)mNavSize);
|
||||
// end enums
|
||||
stream->write(mHeightTolerance);
|
||||
stream->write(mFlocking.mChance);
|
||||
stream->write(mFlocking.mMin);
|
||||
stream->write(mFlocking.mMax);
|
||||
stream->write(mFlocking.mSideStep);
|
||||
#endif // TORQUE_NAVIGATION_ENABLED
|
||||
};
|
||||
|
||||
void AIControllerData::unpackData(BitStream* stream)
|
||||
|
|
@ -631,10 +663,13 @@ void AIControllerData::unpackData(BitStream* stream)
|
|||
Parent::unpackData(stream);
|
||||
|
||||
stream->read(&mMoveTolerance);
|
||||
stream->read(&mFollowTolerance);
|
||||
stream->read(&mAttackRadius);
|
||||
stream->read(&mMoveStuckTolerance);
|
||||
stream->read(&mMoveStuckTestDelay);
|
||||
stream->read(&mHeightTolerance);
|
||||
|
||||
#ifdef TORQUE_NAVIGATION_ENABLED
|
||||
stream->read(&mFollowTolerance);
|
||||
//enums
|
||||
U16 linkFlags;
|
||||
stream->read(&linkFlags);
|
||||
|
|
@ -643,11 +678,11 @@ void AIControllerData::unpackData(BitStream* stream)
|
|||
stream->read(&navSize);
|
||||
mNavSize = (AINavigation::NavSize)(navSize);
|
||||
// end enums
|
||||
stream->read(&mHeightTolerance);
|
||||
stream->read(&(mFlocking.mChance));
|
||||
stream->read(&(mFlocking.mMin));
|
||||
stream->read(&(mFlocking.mMax));
|
||||
stream->read(&(mFlocking.mSideStep));
|
||||
#endif // TORQUE_NAVIGATION_ENABLED
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -875,4 +910,3 @@ void AIFlyingVehicleControllerData::resolveSpeed(AIController* obj, Point3F loca
|
|||
movePtr->x = 0;
|
||||
movePtr->y = obj->mMovement.mMoveSpeed;
|
||||
}
|
||||
#endif //_AICONTROLLER_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue