mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
fix pack/unpack data for AIControllerData's (though we still send nothing, we do need to mark it clientside as false)
more pitchwork for flying vehicle drivers when flocking is irrelevant just path to next node
This commit is contained in:
parent
6efb3843f6
commit
675bdfe6b3
4 changed files with 20 additions and 17 deletions
|
|
@ -777,17 +777,18 @@ void AIFlyingVehicleControllerData::resolvePitch(AIController* obj, Point3F loca
|
||||||
Point3F toTarg = location - aimLoc;
|
Point3F toTarg = location - aimLoc;
|
||||||
toTarg.normalize();
|
toTarg.normalize();
|
||||||
F32 lastPitch = fvo->getSteering().y;
|
F32 lastPitch = fvo->getSteering().y;
|
||||||
|
|
||||||
movePtr->pitch = 0.0f;
|
movePtr->pitch = 0.0f;
|
||||||
F32 dotPitch = -mDot(up, toTarg);
|
F32 dotPitch = mDot(up, toTarg);
|
||||||
|
|
||||||
FlyingVehicleData* db = static_cast<FlyingVehicleData*>(fvo->getDataBlock());
|
FlyingVehicleData* db = static_cast<FlyingVehicleData*>(fvo->getDataBlock());
|
||||||
|
|
||||||
F32 rollAmt = mFabs(fvo->getThrottle()* movePtr->yaw * db->steeringRollForce);
|
F32 rollAmt = mFabs(fvo->getThrottle()* movePtr->yaw / (db->steeringRollForce+1.0));
|
||||||
dotPitch *= 1.0-(mClampF(rollAmt, 0.0,1.0)); // reduce pitch by how much we're rolling
|
dotPitch *= 1.0-(mClampF(rollAmt, 0.0,1.0)); // reduce pitch by how much we're rolling
|
||||||
dotPitch *= M_PI_F;
|
dotPitch *= M_2PI_F;
|
||||||
|
|
||||||
if (mFabs(dotPitch) > 0.05f)
|
if (mFabs(dotPitch) > 0.05f)
|
||||||
movePtr->pitch = dotPitch - lastPitch;
|
movePtr->pitch = dotPitch;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -803,9 +804,7 @@ void AIFlyingVehicleControllerData::resolveSpeed(AIController* obj, Point3F loca
|
||||||
}
|
}
|
||||||
if (!fvo) return;//not a FlyingVehicle
|
if (!fvo) return;//not a FlyingVehicle
|
||||||
|
|
||||||
Parent::resolveSpeed(obj, location, movePtr);
|
|
||||||
|
|
||||||
movePtr->x = 0;
|
movePtr->x = 0;
|
||||||
movePtr->y = mMax(movePtr->y, 0.0f);
|
movePtr->y = obj->mMovement.mMoveSpeed;
|
||||||
}
|
}
|
||||||
#endif //_AICONTROLLER_H_
|
#endif //_AICONTROLLER_H_
|
||||||
|
|
|
||||||
|
|
@ -147,8 +147,8 @@ public:
|
||||||
|
|
||||||
AIControllerData();
|
AIControllerData();
|
||||||
~AIControllerData() {};
|
~AIControllerData() {};
|
||||||
void packData(BitStream* stream) override {};
|
void packData(BitStream* stream) override { Parent::packData(stream); };
|
||||||
void unpackData(BitStream* stream) override {};
|
void unpackData(BitStream* stream) override { Parent::unpackData(stream); };
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
DECLARE_CONOBJECT(AIControllerData);
|
DECLARE_CONOBJECT(AIControllerData);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,8 @@ void AINavigation::repath()
|
||||||
if (mPathData.path.isNull() || !mPathData.owned)
|
if (mPathData.path.isNull() || !mPathData.owned)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mRandI(0, 100) < getCtrl()->mControllerData->mFlocking.mChance)
|
if (mRandI(0, 100) < getCtrl()->mControllerData->mFlocking.mChance && flock())
|
||||||
{
|
{
|
||||||
flock();
|
|
||||||
mPathData.path->mTo = mMoveDestination;
|
mPathData.path->mTo = mMoveDestination;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -296,7 +295,7 @@ void AINavigation::clearPath()
|
||||||
mPathData = PathData();
|
mPathData = PathData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AINavigation::flock()
|
bool 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;
|
||||||
|
|
@ -306,7 +305,7 @@ void AINavigation::flock()
|
||||||
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);
|
||||||
|
|
||||||
F32 maxFlocksq = flockingData.mMax * flockingData.mMax;
|
F32 maxFlocksq = flockingData.mMax * flockingData.mMax;
|
||||||
|
bool flocking = false;
|
||||||
if (getCtrl()->getGoal())
|
if (getCtrl()->getGoal())
|
||||||
{
|
{
|
||||||
Point3F dest = mMoveDestination;
|
Point3F dest = mMoveDestination;
|
||||||
|
|
@ -403,17 +402,22 @@ void AINavigation::flock()
|
||||||
//if we're not jumping...
|
//if we're not jumping...
|
||||||
if (mJump == None)
|
if (mJump == None)
|
||||||
{
|
{
|
||||||
dest.z -= obj->getObjBox().len_z()*0.5;
|
dest.z = obj->getPosition().z;
|
||||||
//make sure we don't run off a cliff
|
//make sure we don't run off a cliff
|
||||||
Point3F zlen(0, 0, getCtrl()->getAIInfo()->mRadius);
|
Point3F zlen(0, 0, getCtrl()->mControllerData->mHeightTolerance);
|
||||||
if (obj->getContainer()->castRay(dest + zlen, dest - zlen, TerrainObjectType | StaticShapeObjectType | StaticObjectType, &info))
|
if (obj->getContainer()->castRay(dest + zlen, dest - zlen, TerrainObjectType | StaticShapeObjectType | StaticObjectType, &info))
|
||||||
|
{
|
||||||
|
if ((mMoveDestination - dest).len() > getCtrl()->mControllerData->mMoveTolerance)
|
||||||
{
|
{
|
||||||
mMoveDestination = dest;
|
mMoveDestination = dest;
|
||||||
|
flocking = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
obj->enableCollision();
|
obj->enableCollision();
|
||||||
|
return flocking;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(AIController, setMoveDestination, void, (Point3F goal, bool slowDown), (true),
|
DefineEngineMethod(AIController, setMoveDestination, void, (Point3F goal, bool slowDown), (true),
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ struct AINavigation
|
||||||
/// Move to the specified node in the current path.
|
/// Move to the specified node in the current path.
|
||||||
void moveToNode(S32 node);
|
void moveToNode(S32 node);
|
||||||
|
|
||||||
void flock();
|
bool flock();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue