Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ShipObject and CollisionManager
#1
(I had never noticed the server sub forum here - sorry for off category posting)



First off - Yes I know JTL is only a stone's throw away, and I'm not looking to make a pseudo-JTL placeholder.

I am looking to make the little atmospheric flight code snippit in PlayerCreationManager viable, though...

in MMOCoreORB/src/server/zone/managers/collision/CollisionManager.cpp   - we have this:




bool CollisionManager::checkShipCollision(ShipObject* ship, const Vector3& targetPosition, Vector3& collisionPoint) {
    Zone* zone = ship->getZone();

    if (zone == NULL)
        return false;

    TerrainManager* terrainManager = zone->getPlanetManager()->getTerrainManager();

    if (terrainManager->getProceduralTerrainAppearance() != NULL) {
        float height = terrainManager->getHeight(targetPosition.getX(), targetPosition.getY());

        float waterHeight = -16368.f;

        if (terrainManager->getWaterHeight(targetPosition.getY(), targetPosition.getY(), waterHeight))
            height = Math::max(waterHeight, height);

        if (height > targetPosition.getZ()) {
            collisionPoint = targetPosition;
            collisionPoint.setZ(height);
            //ship->info("colliding with terrain", true);
            return true;
        }
    }

    Vector3 rayOrigin = ship->getWorldPosition();

    rayOrigin.set(rayOrigin.getX(), rayOrigin.getY(), rayOrigin.getZ());

    Vector3 rayEnd;
    rayEnd.set(targetPosition.getX(), targetPosition.getY(), targetPosition.getZ());

    float dist = rayEnd.distanceTo(rayOrigin);
    float intersectionDistance;
    Triangle* triangle = NULL;

    SortedVector<ManagedReference<QuadTreeEntry*> > objects(512, 512);
    zone->getInRangeObjects(targetPosition.getX(), targetPosition.getY(), 512, &objects, true);

    for (int i = 0; i < objects.size(); ++i) {
        const AppearanceTemplate *app = NULL;

        SceneObject* scno = static_cast<SceneObject*>(objects.get(i).get());

        try {
            app = getCollisionAppearance(scno, -1);

            if (app == NULL)
                continue;

        } catch (Exception& e) {
            app = NULL;
        } catch (...) {
            throw;
        }

        if (app != NULL) {
            //moving ray to model space

            try {
                Ray ray = convertToModelSpace(rayOrigin, rayEnd, scno);

                //structure->info("checking ray with building dir" + String::valueOf(structure->getDirectionAngle()), true);

                if (app->intersects(ray, dist, intersectionDistance, triangle, true)) {

                    //rayOrigin.set(rayOrigin.getX(), rayOrigin.getY(), rayOrigin.getZ());
                    Vector3 direction = rayEnd - rayOrigin;
                    direction.normalize();
                    //intersectionDistance -= 0.5f;

                    collisionPoint.set(rayOrigin.getX() + (direction.getX() * intersectionDistance), rayOrigin.getY() + (direction.getY() * intersectionDistance), rayOrigin.getZ() + (direction.getZ() * intersectionDistance));
                    //ship->info("colliding with building", true);

                    return true;
                }
            } catch (Exception& e) {
                ship->error(e.getMessage());
            } catch (...) {
                throw;
            }


        }
    }

    return false;




---------------------------------------------------
I think I've extracted the bit necessary here to change the actual collision physics for ShipObject.

I wish I could do it myself...   what seems to need done is this:

Make it so the ShipObject never even comes within range of the terrain OR static objects for the collision bug to happen.

I have gone into the ShipObjectImplementation and tried to add a simple math fix there, but it seems that's already the way it's setup, literally there is a Z+10 there when it's getting your player object coords.



There's no need to hide any knowledge........ let's get all of these features working for everyone!
 
Reply
  



Forum Jump:


Browsing: 1 Guest(s)