コード例 #1
0
void plPhysicalControllerCore::IApply(float delSecs)
{
    fSimLength = delSecs;

    // Match controller to owner if transform has changed since the last frame
    plSceneObject* so = plSceneObject::ConvertNoRef(fOwner->ObjectIsLoaded());
    const hsMatrix44& l2w = so->GetCoordinateInterface()->GetLocalToWorld();
    if (!CompareMatrices(fLastGlobalLoc, l2w, 0.0001f))
        SetGlobalLoc(l2w);

    if (fEnabled)
    {
        // Convert velocity from avatar to world space
        if (!fLinearVelocity.IsEmpty())
        {
            fLinearVelocity = l2w * fLinearVelocity;

            const plCoordinateInterface* subworldCI = GetSubworldCI();
            if (subworldCI)
                fLinearVelocity = subworldCI->GetWorldToLocal() * fLinearVelocity;
        }

        fMovementStrategy->Apply(delSecs);
    }
}
コード例 #2
0
void plPhysicalControllerCore::UpdateSubstepNonPhysical()
{
    // When we're in non-phys or a behavior we can't go through the rest of the function
    // so we need to get out early, but we need to update the current position if we're
    // in a subworld.
    plSceneObject* so = plSceneObject::ConvertNoRef(fOwner->ObjectIsLoaded());
    const plCoordinateInterface* ci = GetSubworldCI();
    if (ci && so)
    {
        const hsMatrix44& soL2W = so->GetCoordinateInterface()->GetLocalToWorld();
        const hsMatrix44& ciL2W = ci->GetLocalToWorld();
        hsMatrix44 l2w =GetPrevSubworldW2L()* soL2W;
        l2w = ciL2W * l2w;
        hsMatrix44 w2l;
        l2w.GetInverse(&w2l);
        ((plCoordinateInterface*)so->GetCoordinateInterface())->SetTransform(l2w, w2l);
        ((plCoordinateInterface*)so->GetCoordinateInterface())->FlushTransform();
        SetGlobalLoc(l2w);
    }


}