From e332609003048069cd6d236d629e3d4b71b05efc Mon Sep 17 00:00:00 2001 From: Azaezel Date: Sun, 13 Jul 2014 12:24:17 -0500 Subject: [PATCH] requested alterations. bool AIPlayer::checkLosClear(Point3F _pos) removed as not fit for purpose at the present time. Something to revisit when I'm spread less thin, or give someone else a crack at it. --- Engine/source/T3D/aiPlayer.cpp | 73 +++++++++++++++------------------- Engine/source/T3D/aiPlayer.h | 1 - 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/Engine/source/T3D/aiPlayer.cpp b/Engine/source/T3D/aiPlayer.cpp index 0c9b930fe..31ada9970 100644 --- a/Engine/source/T3D/aiPlayer.cpp +++ b/Engine/source/T3D/aiPlayer.cpp @@ -609,17 +609,22 @@ DefineEngineMethod( AIPlayer, getAimObject, S32, (),, bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled) { if (!isServerObject()) return false; - if (!(bool(target))) + if (!target) { target = mAimObject.getPointer(); - if (!(bool(target))) + if (!target) return false; } if (_checkEnabled) { - ShapeBase *shapeBaseCheck = dynamic_cast(target); - if (shapeBaseCheck) - if (shapeBaseCheck->getDamageState() != Enabled) return false; + if (target->getTypeMask() & ShapeBaseObjectType) + { + ShapeBase *shapeBaseCheck = static_cast(target); + if (shapeBaseCheck) + if (shapeBaseCheck->getDamageState() != Enabled) return false; + } + else + return false; } RayInfo ri; @@ -652,42 +657,34 @@ bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled) return hit; } - -bool AIPlayer::checkLosClear(Point3F _pos) -{ - if (!isServerObject()) return false; - - RayInfo ri; - - disableCollision(); - - Point3F muzzlePoint; - getMuzzlePointAI(0, &muzzlePoint); - gServerContainer.castRay(muzzlePoint, _pos, sAIPlayerLoSMask, &ri); - bool emptySpace = bool(ri.object == NULL); - enableCollision(); - return emptySpace; -} - DefineEngineMethod(AIPlayer, checkInLos, bool, (ShapeBase* obj, bool useMuzzle, bool checkEnabled),(NULL, false, false), - "@brief Check for an object in line of sight.\n" - "@obj Object to check. if blank it will check the current target.\n" - "@useMuzzle Use muzzle position (otherwise use eye position).\n" - "@checkEnabled check if the object is not disabled.\n") + "@brief Check whether an object is in line of sight.\n" + "@obj Object to check. (If blank, it will check the current target).\n" + "@useMuzzle Use muzzle position. Otherwise use eye position. (defaults to false).\n" + "@checkEnabled check whether the object can take damage and if so is still alive.(Defaults to false)\n") { return object->checkInLos(obj, useMuzzle, checkEnabled); } - bool AIPlayer::checkInFoV(GameBase* target, F32 camFov, bool _checkEnabled) { if (!isServerObject()) return false; - if (!(bool(target))) return false; + if (!target) + { + target = mAimObject.getPointer(); + if (!target) + return false; + } if (_checkEnabled) { - ShapeBase *shapeBaseCheck = dynamic_cast(target); - if (shapeBaseCheck) - if (shapeBaseCheck->getDamageState() != Enabled) return false; + if (target->getTypeMask() & ShapeBaseObjectType) + { + ShapeBase *shapeBaseCheck = static_cast(target); + if (shapeBaseCheck) + if (shapeBaseCheck->getDamageState() != Enabled) return false; + } + else + return false; } MatrixF cam = getTransform(); @@ -699,11 +696,7 @@ bool AIPlayer::checkInFoV(GameBase* target, F32 camFov, bool _checkEnabled) camFov = mDegToRad(camFov) / 2; - Point3F shapePos; - // Use the render transform instead of the box center - // otherwise it'll jitter. - MatrixF srtMat = target->getTransform(); - srtMat.getColumn(3, &shapePos); + Point3F shapePos = target->getBoxCenter(); VectorF shapeDir = shapePos - camPos; // Test to see if it's within our viewcone, this test doesn't // actually match the viewport very well, should consider @@ -714,10 +707,10 @@ bool AIPlayer::checkInFoV(GameBase* target, F32 camFov, bool _checkEnabled) } DefineEngineMethod(AIPlayer, checkInFoV, bool, (ShapeBase* obj, F32 fov, bool checkEnabled), (NULL, 45.0f, false), - "@brief Check for an object within a specified veiw cone.\n" - "@obj Object to check. if blank it will check the current target.\n" - "@fov view angle (in degrees)\n" - "@checkEnabled check if the object is not disabled.\n") + "@brief Check whether an object is within a specified veiw cone.\n" + "@obj Object to check. (If blank, it will check the current target).\n" + "@fov view angle in degrees.(Defaults to 45)\n" + "@checkEnabled check whether the object can take damage and if so is still alive.(Defaults to false)\n") { return object->checkInFoV(obj, fov, checkEnabled); } \ No newline at end of file diff --git a/Engine/source/T3D/aiPlayer.h b/Engine/source/T3D/aiPlayer.h index 851482021..86da43edb 100644 --- a/Engine/source/T3D/aiPlayer.h +++ b/Engine/source/T3D/aiPlayer.h @@ -81,7 +81,6 @@ public: Point3F getAimLocation() const { return mAimLocation; } void clearAim(); bool checkInLos(GameBase* target = NULL, bool _useMuzzle = false, bool _checkEnabled = false); - bool checkLosClear(Point3F _pos); bool checkInFoV(GameBase* target = NULL, F32 camFov = 45.0f, bool _checkEnabled = false); // Movement sets/gets