bool DynamicMapTree::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const { // Don't calculate hit position, if wrong src/dest points provided! if (!VMAP::CheckPosition(x1, y1, z1) || !VMAP::CheckPosition(x2, y2, z2)) return false; if (!size()) return true; Vector3 v1(x1, y1, z1), v2(x2, y2, z2); float maxDist = (v2 - v1).magnitude(); if (!G3D::fuzzyGt(maxDist, 0)) return true; G3D::Ray r(v1, (v2 - v1) / maxDist); DynamicTreeIntersectionCallback callback(phasemask); impl.intersectRay(r, callback, maxDist, v2); // search for intersect only one surface (may appears if method called for check // LOS for objects, placed into other objects (cast "in GO" for example) // MAY HEAVILY INCREASE CPU USAGE! /dev/rsa bool result = !callback.did_hit; if (!result && sWorld.getConfig(CONFIG_BOOL_DYNAMIC_VMAP_DOUBLE_CHECK)) { Vector3 vRes1, vRes2; bool ray1 = getObjectHitPos(phasemask, v1, v2, vRes1, 0.0f); bool ray2 = getObjectHitPos(phasemask, v2, v1, vRes2, 0.0f); if ((vRes1 - vRes2).magnitude() < M_NULL_F) result = true; } return result; }
bool DynamicMapTree::getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float pModifyDist) const { Vector3 pos1 = Vector3(x1, y1, z1); Vector3 pos2 = Vector3(x2, y2, z2); Vector3 resultPos; bool result = getObjectHitPos(phasemask, pos1, pos2, resultPos, pModifyDist); rx = resultPos.x; ry = resultPos.y; rz = resultPos.z; return result; }
bool DynamicMapTree::getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float pModifyDist) const { // Don't calculate hit position, if wrong src/dest points provided! if (!VMAP::CheckPosition(x1, y1, z1) || !VMAP::CheckPosition(x2, y2, z2)) return false; Vector3 pos1 = Vector3(x1, y1, z1); Vector3 pos2 = Vector3(x2, y2, z2); Vector3 resultPos; bool result = getObjectHitPos(phasemask, pos1, pos2, resultPos, pModifyDist); rx = resultPos.x; ry = resultPos.y; rz = resultPos.z; return result; }