mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-14 23:07:48 -04:00
In work
This commit is contained in:
@@ -48,6 +48,8 @@ void CollisionCallbacks::install()
|
||||
int const asteroid = static_cast<int>(SharedObjectTemplate::GOT_misc_asteroid);
|
||||
int const miningAsteroidStatic = static_cast<int>(SharedObjectTemplate::GOT_ship_mining_asteroid_static);
|
||||
int const miningAsteroidDynamic = static_cast<int>(SharedObjectTemplate::GOT_ship_mining_asteroid_dynamic);
|
||||
int const building = static_cast<int>(SharedObjectTemplate::GOT_building);
|
||||
int const installation = static_cast<int>(SharedObjectTemplate::GOT_installation);
|
||||
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, shipFighter, shipCapital);
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, shipFighter, shipStation);
|
||||
@@ -72,7 +74,10 @@ void CollisionCallbacks::install()
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, miningAsteroidDynamic, asteroid);
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, miningAsteroidDynamic, shipStation);
|
||||
|
||||
// Handle Atmo Flight
|
||||
CollisionCallbackManager::registerDoCollisionWithTerrainFunction(CollisionCallbacksNamespace::onDoCollisionWithTerrain);
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, shipFighter, building);
|
||||
CollisionCallbackManager::registerOnHitFunction(CollisionCallbacksNamespace::onHitDoCollisionWith, shipFighter, installation);
|
||||
|
||||
ExitChain::add(CollisionCallbacksNamespace::remove, "CollisionCallbacks");
|
||||
}
|
||||
@@ -133,7 +138,6 @@ bool CollisionCallbacksNamespace::onDoCollisionWithTerrain(Object * const object
|
||||
{
|
||||
ShipController * const shipController = safe_cast<ShipController *>(shipObject->getController());
|
||||
NOT_NULL(shipController);
|
||||
REPORT_LOG(true, ("responding to collision"));
|
||||
shipController->respondToCollision(result.m_deltaToMoveBack_p, result.m_newReflection_p, result.m_normalOfSurface_p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -164,11 +164,12 @@ namespace ContainerInterfaceNamespace
|
||||
params.addParam(destId);
|
||||
params.addParam(transfererId);
|
||||
params.addParam(item.getNetworkId());
|
||||
GameScriptObject * const scriptObject = source->getScriptObject();
|
||||
|
||||
//-- Handle source container's scripts.
|
||||
if (source->getScriptObject())
|
||||
if (scriptObject)
|
||||
{
|
||||
if (source->getScriptObject()->trigAllScripts(Scripting::TRIG_ABOUT_TO_LOSE_ITEM, params) == SCRIPT_OVERRIDE)
|
||||
if (scriptObject->trigAllScripts(Scripting::TRIG_ABOUT_TO_LOSE_ITEM, params) == SCRIPT_OVERRIDE)
|
||||
{
|
||||
error = Container::CEC_BlockedByScript;
|
||||
LOG("ScriptInvestigation", ("Source tried to prevent container transfer"));
|
||||
|
||||
+14
-20
@@ -232,29 +232,21 @@ bool CollisionCallbackManager::intersectAndReflectWithTerrain(Object * const obj
|
||||
Vector const begin_w(queryCapsule_w.getPointA());
|
||||
Vector const end_w(queryCapsule_w.getPointB() + direction_w * radius);
|
||||
|
||||
// DEBUG_REPORT_LOG(ms_debugReport, ("terrain begin = %f %f %f\n", begin_w.x, begin_w.y, begin_w.z));
|
||||
// DEBUG_REPORT_LOG(ms_debugReport, ("terrain end = %f %f %f\n", end_w.x, end_w.y, end_w.z));
|
||||
// DEBUG_REPORT_LOG(ms_debugReport, ("terrain direction = %f %f %f\n", direction_w.x, direction_w.y, direction_w.z));
|
||||
// DEBUG_REPORT_LOG(ms_debugReport, ("terrain length = %f\n", deltaTraveled_w.magnitude()));
|
||||
|
||||
REPORT_LOG(true, ("ship begin = %f %f %f\n", begin_w.x, begin_w.y, begin_w.z));
|
||||
REPORT_LOG(true, ("ship end = %f %f %f\n", end_w.x, end_w.y, end_w.z));
|
||||
REPORT_LOG(true, ("ship direction = %f %f %f\n", direction_w.x, direction_w.y, direction_w.z));
|
||||
REPORT_LOG(true, ("ship length = %f\n", deltaTraveled_w.magnitude()));
|
||||
DEBUG_REPORT_LOG(true, ("ship begin = %f %f %f\n", begin_w.x, begin_w.y, begin_w.z));
|
||||
DEBUG_REPORT_LOG(true, ("ship end = %f %f %f\n", end_w.x, end_w.y, end_w.z));
|
||||
DEBUG_REPORT_LOG(true, ("ship direction = %f %f %f\n", direction_w.x, direction_w.y, direction_w.z));
|
||||
DEBUG_REPORT_LOG(true, ("ship length = %f\n", deltaTraveled_w.magnitude()));
|
||||
|
||||
TerrainObject const * const terrainObject = TerrainObject::getConstInstance();
|
||||
if (terrainObject != 0)
|
||||
{
|
||||
REPORT_LOG(true, ("found possible ground collision - checking collision\n"));
|
||||
CollisionInfo info;
|
||||
|
||||
float bh = 0.0f;
|
||||
terrainObject->getHeightForceChunkCreation(Vector(begin_w.x, 0.f, begin_w.z), bh);
|
||||
REPORT_LOG(true,("Terrain Height: begin: %f\n", bh));
|
||||
|
||||
if (terrainObject->collide (begin_w, end_w, info))
|
||||
{
|
||||
REPORT_LOG(true, ("collided with terrain\n"));
|
||||
#ifdef _DEBUG
|
||||
// calculate the parametric time for logging
|
||||
float const actualDistance = begin_w.magnitudeBetween(info.getPoint());
|
||||
@@ -281,21 +273,20 @@ bool CollisionCallbackManager::intersectAndReflectWithTerrain(Object * const obj
|
||||
|
||||
return true;
|
||||
}
|
||||
// Check our terrain elevation and add 5m to it - this will be our "floor" for allowable flight
|
||||
// Get the elevation at the current point. This will be our "floor" for allowable flight
|
||||
// if below that, then we've "collided" and at the very least, we need to be put somewhere ABOVE
|
||||
// the terrain.
|
||||
else if(bh >= begin_w.y) {
|
||||
// we are below the allowable elevation
|
||||
// We are at or below the allowable elevation and there was no identified collision to spheres.
|
||||
|
||||
// Create a theoretical intersection point. We need to "fake" this point as the main system
|
||||
// that was originally used is not working properly - suggesting more is at play that was originally expected.
|
||||
// implement this to avoid any unwanted bugs - rework when the bugs are found and fixed.
|
||||
// that was originally used to detect spheres along the trajectory of the ship is not working properly
|
||||
// suggesting more is at play that was originally expected. Implement this to avoid any unwanted bugs
|
||||
// and rework when the bugs are found and fixed (i.e. why would terrain have or NOT have spheres?)
|
||||
Vector const & intersection = Vector(begin_w.x, bh, begin_w.z);
|
||||
Vector normal;
|
||||
|
||||
// Recreate the necessary geometry in light of NOT having the correct geometry.
|
||||
info.setObject(terrainObject);
|
||||
info.setPoint(terrainObject->rotateTranslate_w2o(intersection));
|
||||
// Make sure we can actually get a Normal Vector from the plane at intersection within this chunk.
|
||||
if(terrainObject->getNormalOfPlaneAtPoint(intersection, normal)){
|
||||
info.setNormal(normal);
|
||||
}
|
||||
@@ -303,7 +294,10 @@ bool CollisionCallbackManager::intersectAndReflectWithTerrain(Object * const obj
|
||||
return false;
|
||||
}
|
||||
|
||||
REPORT_LOG(true, ("Intersection: %f %f %f\n", info.getPoint().x, info.getPoint().y, info.getPoint().z));
|
||||
// Recreate the rest of the necessary geometry needed to reflect the ship (i.e. "bounce") in light of
|
||||
// NOT having the correct geometry.
|
||||
info.setObject(terrainObject);
|
||||
info.setPoint(terrainObject->rotateTranslate_w2o(intersection));
|
||||
|
||||
result.m_pointOfCollision_p = info.getPoint();
|
||||
result.m_normalOfSurface_p = info.getNormal();
|
||||
|
||||
+1
-13
@@ -372,17 +372,14 @@ bool ServerProceduralTerrainAppearance::ServerChunk::getNormalAtPoint (const Vec
|
||||
if (pos.x < vmin.x || pos.x > vmax.x || pos.z < vmin.z || pos.z > vmax.z)
|
||||
{
|
||||
DEBUG_WARNING (true, ("called getNormalAtPoint for position not within chunk"));
|
||||
REPORT_LOG(true, ("position not within chunk\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
int tileX;
|
||||
int tileZ;
|
||||
_findTileXz(pos, tileX, tileZ);
|
||||
if (isExcluded(tileX, tileZ)) {
|
||||
REPORT_LOG(true, ("tile is excluded\n"));
|
||||
if (isExcluded(tileX, tileZ))
|
||||
return false;
|
||||
}
|
||||
|
||||
//-- find out which tile this intersects
|
||||
const Vector start (pos.x, vmax.y + 0.1f, pos.z);
|
||||
@@ -395,7 +392,6 @@ bool ServerProceduralTerrainAppearance::ServerChunk::getNormalAtPoint (const Vec
|
||||
int const numberOfTilesPerChunk = m_proceduralTerrainAppearance.getNumberOfTilesPerChunk();
|
||||
int const tileIndex = tileZ * numberOfTilesPerChunk + tileX;
|
||||
const int offset = tileIndex * 8;
|
||||
REPORT_LOG(true, ("Offset: %d\n", offset));
|
||||
|
||||
int k;
|
||||
for (k = offset; k < offset + 8; ++k)
|
||||
@@ -405,12 +401,9 @@ bool ServerProceduralTerrainAppearance::ServerChunk::getNormalAtPoint (const Vec
|
||||
Vector planeNormal = plane.getNormal ();
|
||||
|
||||
if(!plane.findIntersection(start, end, intersection)) {
|
||||
REPORT_LOG(true, ("Intersection was not found\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
REPORT_LOG(true, ("Checking plane %d, dir.dot: %f, intersection: %f, %f, %f\n", k, dir.dot(planeNormal), intersection.x, intersection.y, intersection.z));
|
||||
|
||||
if ((dir.dot (planeNormal) < 0.f) && (plane.findIntersection (start, end, intersection)))
|
||||
{
|
||||
const int i0 = (*ms_indexList) [k * 3 + 0];
|
||||
@@ -420,7 +413,6 @@ bool ServerProceduralTerrainAppearance::ServerChunk::getNormalAtPoint (const Vec
|
||||
const Vector& v0 = (*m_vertexList) [i0];
|
||||
const Vector& v1 = (*m_vertexList) [i1];
|
||||
const Vector& v2 = (*m_vertexList) [i2];
|
||||
REPORT_LOG(true, ("Found good plane: %f, %f, %f : checking vertexes.\n", v0, v1, v2));
|
||||
|
||||
DenormalizedLine2d const line01 (Vector2d (v0.x, v0.z), Vector2d (v1.x, v1.z));
|
||||
DenormalizedLine2d const line12 (Vector2d (v1.x, v1.z), Vector2d (v2.x, v2.z));
|
||||
@@ -431,12 +423,9 @@ bool ServerProceduralTerrainAppearance::ServerChunk::getNormalAtPoint (const Vec
|
||||
line20.computeDistanceTo (Vector2d (start.x, start.z)) <= 0)
|
||||
{
|
||||
*normal = planeNormal;
|
||||
REPORT_LOG(true, ("Found on this plane: %f, %f, %f\n", v0, v1, v2));
|
||||
return true;
|
||||
}
|
||||
REPORT_LOG(true, ("Not on this plane. Distances: %f, %f, %f\n", line01.computeDistanceTo (Vector2d (start.x, start.z)), line12.computeDistanceTo (Vector2d (start.x, start.z)), line20.computeDistanceTo (Vector2d (start.x, start.z))));
|
||||
}
|
||||
REPORT_LOG(true, ("Not on this intersection.\n"));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1249,7 +1238,6 @@ bool ServerProceduralTerrainAppearance::getNormalOfPlaneAtPoint(const Vector& po
|
||||
|
||||
bool ServerProceduralTerrainAppearance::collide(Vector const & start_o, Vector const & end_o, CollideParameters const & /*collideParameters*/, CollisionInfo & result) const
|
||||
{
|
||||
REPORT_LOG(true, ("Checking collision after rotation - Start Y: %f, End Y: %f\n", start_o.y, end_o.y));
|
||||
ChunkList chunkList;
|
||||
m_sphereTree.findOnSegment (start_o, end_o, chunkList);
|
||||
std::stable_sort(chunkList.begin(), chunkList.end(), CollisionChunkSorter(start_o));
|
||||
|
||||
@@ -152,7 +152,6 @@ bool TerrainAppearance::getHeightForceChunkCreation (const Vector& /*position_o*
|
||||
|
||||
bool TerrainAppearance::getNormalOfPlaneAtPoint (const Vector& /*position_w*/, Vector& /*normal*/) const
|
||||
{
|
||||
REPORT_LOG(true, ("Not implemented.\n"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user