Пример #1
0
bool plPXPhysical::Should_I_Trigger(bool enter, hsPoint3& pos)
{
    // see if we are inside the detector hull, if so, then don't trigger
    bool trigger = false;
    bool inside = IsObjectInsideHull(pos);
    if ( !inside)
    {
        trigger = true;
        fInsideConvexHull = enter;
    }
    else
    {
        // catch those rare cases on slow machines that miss the collision before avatar penetrated the face
        if (enter && !fInsideConvexHull)
        {
#ifdef PHYSX_SAVE_TRIGGERS_WORKAROUND
            trigger = true;
            fInsideConvexHull = enter;
            DetectorLogSpecial("**>Saved a missing enter collision: %s",GetObjectKey()->GetName().c_str());
#else
            DetectorLogSpecial("**>Could have saved a missing enter collision: %s",GetObjectKey()->GetName().c_str());
#endif PHYSX_SAVE_TRIGGERS_WORKAROUND
        }
    }

    return trigger;
}
Пример #2
0
//
// TESTING SDL
// Send phys sendState msg to object's plPhysicalSDLModifier
//
bool plPXPhysical::DirtySynchState(const char* SDLStateName, uint32_t synchFlags )
{
    if (GetObjectKey())
    {
        plSynchedObject* so=plSynchedObject::ConvertNoRef(GetObjectKey()->ObjectIsLoaded());
        if (so)
        {
            fLastSyncTime = hsTimer::GetSysSeconds();
            return so->DirtySynchState(SDLStateName, synchFlags);
        }
    }

    return false;
}
Пример #3
0
// Called after the simulation has run....sends new positions to the various scene objects
// *** want to do this in response to an update message....
void plPXPhysical::SendNewLocation(bool synchTransform, bool isSynchUpdate)
{
    // we only send if:
    // - the body is active or forceUpdate is on
    // - the mass is non-zero
    // - the physical is not passive
    bool bodyActive = !fActor->isSleeping();
    bool dynamic = fActor->isDynamic();
    
    if ((bodyActive || isSynchUpdate) && dynamic)// && fInitialTransform)
    {
        plProfile_Inc(MaySendLocation);

        if (!GetProperty(plSimulationInterface::kPassive))
        {
            hsMatrix44 curl2w = fCachedLocal2World;
            // we're going to cache the transform before sending so we can recognize if it comes back
            IGetTransformGlobal(fCachedLocal2World);

            if (!CompareMatrices(curl2w, fCachedLocal2World, .0001f))
            {
                plProfile_Inc(LocationsSent);
                plProfile_BeginLap(PhysicsUpdates, GetKeyName().c_str());

                // quick peek at the translation...last time it was corrupted because we applied a non-unit quaternion
//              hsAssert(real_finite(fCachedLocal2World.fMap[0][3]) &&
//                       real_finite(fCachedLocal2World.fMap[1][3]) &&
//                       real_finite(fCachedLocal2World.fMap[2][3]), "Bad transform outgoing");

                if (fCachedLocal2World.GetTranslate().fZ < kMaxNegativeZPos)
                {
                    SimLog("Physical %s fell to %.1f (%.1f is the max).  Suppressing.", GetKeyName().c_str(), fCachedLocal2World.GetTranslate().fZ, kMaxNegativeZPos);
                    // Since this has probably been falling for a while, and thus not getting any syncs,
                    // make sure to save it's current pos so we'll know to reset it later
                    DirtySynchState(kSDLPhysical, plSynchedObject::kBCastToClients);
                    IEnable(false);
                }

                hsMatrix44 w2l;
                fCachedLocal2World.GetInverse(&w2l);
                plCorrectionMsg *pCorrMsg = new plCorrectionMsg(GetObjectKey(), fCachedLocal2World, w2l, synchTransform);
                pCorrMsg->Send();
                if (fProxyGen)
                    fProxyGen->SetTransform(fCachedLocal2World, w2l);
                plProfile_EndLap(PhysicsUpdates, GetKeyName().c_str());
            }
        }
    }
}
Пример #4
0
 /// \brief
 ///   Gets the key of the light source.
 /// 
 /// This function wraps around GetObjectKey of the base class.
 /// 
 /// The key can be set in vForge or via SetObjectKey. It can be used to seach for lights in the
 /// scene via key.
 /// 
 /// See Vision::Game.SearchLight.
 /// 
 /// \return
 ///   const char *key: The key of the light source.
 inline const char *GetKey() const
 {
   return GetObjectKey();
 }