Physics bugs under -2000

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.

Physics bugs under -2000

Postby Sirius » Sun Feb 19, 2012 12:00 pm

Hi everyone,

I found a strange behavior for the physics of kickables objects, which also affects markers.
It might explains why dynamic objects appear to be floating somewhere in the Age on the next link-in, and why some markers in a few places can't be collected.
I was not sure if it has already been found, so I thought it might be a good idea to post this here.


Recently I found something strange in my Simulation.0.elf log file:
Code: Select all
Physical JumpBlocker loaded out of range state.  Forcing initial state to server.
[others]
Physical JumpBlocker fell to -2014.5 (-2000.0 is the max).  Suppressing.
This immediately reminded me of a bug Diafero found and posted on another thread and I'm sure it is related:
Diafero wrote:Hans recently showed me a bug which I could now reproduce and narrow down: It seems that if you create a marker mission and add a marker of which the z coordinate is below -2000, it is not possible to collect that marker. When you play the mission, you can see it, but when you go through it, nothing happens. The only age I found that goes so deep is Vaiskor 2. I found a mountain there where you can easily walk across this invisible border, and indeed from a bunch of markers I placed there, all the ones below -2000 where non-collectable (-2007 did not work, -1991 worked). This happens both online and offline. Does anyone have any idea what this could be caused by? 2000 does not sound like a number overflow, and besides, markers in the outer scene of Gahreesen (which is at z value +10000) work fine.
Is there an UU version of Vaiskor 2, so one could verify if this is POTS-specific?


As this sounded quite strange to me, I looked for "is the max)" in the MOULa C++ files.
I found it in the file plPXPhysical.cpp:
Code: Select all
void plPXPhysical::SendNewLocation(hsBool synchTransform, hsBool isSynchUpdate)
{
   // we only send if:
   // - the body is active or forceUpdate is on
   // - the mass is non-zero
   // - the physical is not passive
   hsBool bodyActive = !fActor->isSleeping();
   hsBool 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());

            // 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(), 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 = TRACKED_NEW plCorrectionMsg(GetObjectKey(), fCachedLocal2World, w2l, synchTransform);
            pCorrMsg->Send();
            if (fProxyGen)
               fProxyGen->SetTransform(fCachedLocal2World, w2l);
            plProfile_EndLap(PhysicsUpdates, GetKeyName());
         }
      }
   }
}
... this part of code seems to be executed each time the physics of an object have to move. This test...:
Code: Select all
            if (fCachedLocal2World.GetTranslate().fZ < kMaxNegativeZPos) // kMaxNegativeZPos has a value of -2000.0
            {
               SimLog("Physical %s fell to %.1f (%.1f is the max).  Suppressing.", GetKeyName(), 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);
            }
...was added to make sure an object that fell from the collision area won't fall forever. If the object falls under 2000 units (even though it is still on a collider), it will freeze (I assume it from "IEnable(false)"), and should be restored to its default position upon next link-in, which unfortunately isn't the case as it's floating somewhere else (I remember cones being stuck under the canyon bridge in the city). The second problem is that it seems to affect every physical that can move (animated or warped, as Markers), which we don't want.

I don't know if it can be fixed, but if it could freeze the physics of only kickables objects it would be great.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Physics bugs under -2000

Postby Tsar Hoikas » Sun Feb 19, 2012 1:50 pm

Code: Select all
hsBool dynamic = fActor->isDynamic() && !fActor->readBodyFlag(NX_BF_KINEMATIC);


should filter out non-kickables.

However, no one, I repeat no one should be building an age at -2000. If someone is doing this, then they shouldn't be.
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1798
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Physics bugs under -2000

Postby diafero » Mon Feb 20, 2012 4:12 am

I think Vaiskor2 is the only age doing that... and it will hardly be changed ;-)
(but if we are ever able to convert ages to MOUL... Drizzle has the functionality to translate an age, which we used to fix swimming in Ahnonay. Maybe it can also move Vaiskor 2 up, which uses much less fancy Plasma stuff than Ahnonay)
I prefer e-mails to "diafero arcor de" (after adding the at and the dot) over PMs.

"Many people's horizon is a circle with a radius of zero. They call it their point of view."

Deep Island Shard | Offline KI
diafero
Deep Island Admin
 
Posts: 2783
Joined: Mon May 05, 2008 5:50 am
Location: Germany

Re: Physics bugs under -2000

Postby Tsar Hoikas » Mon Feb 20, 2012 5:11 am

Oh, yeah.... That's an old one. :lol:
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1798
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Physics bugs under -2000

Postby Sirius » Mon Feb 20, 2012 10:26 am

Well, this seemed a strange workaround to me...

Tsar Hoikas wrote:
Code: Select all
hsBool dynamic = fActor->isDynamic() && !fActor->readBodyFlag(NX_BF_KINEMATIC);

should filter out non-kickables.
As far as I know, a kickable has a non-null mass and MemberGroup="kGroupDynamic " and CollideGroup="kGroupStatic kGroupDynamic ".
The markers has a mass of 1 (to tell Uru to calculate the physics from the object's origin), but its MemberGroup is kGroupDetector and CollideGroup is empty.
And my JumpBlocker object is just an animated collider not linked to any subworld (and therefore has a mass of 1), with a kGroupStatic MemberGroup+empty CollideGroup. I'll tell you the truth, I don't know why it was under 2000 so this might just be an error from me.

That's what worried me the most. I might check again if the JumpBlocker collider really is at the correct position though.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Physics bugs under -2000

Postby Tsar Hoikas » Mon Feb 20, 2012 10:34 am

Animated kStatic? That's the problem. Set it to dynamic.

Sorry for the rushed response, but I'm on the way out.
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1798
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Physics bugs under -2000

Postby Sirius » Mon Feb 20, 2012 11:21 am

Tsar Hoikas wrote:Sorry for the rushed response, but I'm on the way out.
Not a problem, that's fine.

Tsar Hoikas wrote:Animated kStatic? That's the problem. Set it to dynamic.
kGroupStatic can be animated fine (except collision with avatar will be better in a subworld). I just didn't noticed other animated colliders had kPinned property, while this one somehow didn't have it.
In fact, I completely messed up with Mass and MemberGroup, etc. Mass tells the physics to be calculated from the object's origin (that's why it is sometimes used with animations), however mass affects the object even though it doesn't have to be kickable itself (I guess this "kickable" is managed by MemberGroup and CollideGroup). That's where I was wrong.
Which means my collider was not kickable but yet falling from the Age.
Sorry about that :oops: . Just forget what I said.
Trust me, I usually avoid messing up with all these physics properties, especially animated colliders without subworlds.


So, our marker collision is affected by gravity but doesn't fall because of kPinned... and because of the effect of gravity Uru thinks it is falling. Ok, I understand better, but I think it should not care about the object's location if it has kPinned. I guess there is a good reason for it anyway.
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France

Re: Physics bugs under -2000

Postby Tsar Hoikas » Mon Feb 20, 2012 1:50 pm

Okay, now that I have time to write a response...

Never animate a static physical. The result of that operation is undefined. It might work now, but it also might not later.

There are two kinds of dynamic physicals in CWE. Regular dynamics that respond to gravity and other forces (the default), and kinematics, which do not respond to gravity or other forces (the programmer must move them himself, which is accomplished by animation transformations). Since kinematics do not respond to forces, mass and the other values do not respond. To make your dynamic kinematic, you must apply the kPhysAnim flag.

Now, for some more obvious flag stuff... If you're making a detector, you want the kGroupDetector to be set; otherwise, PhysX will not report enters/exits to your region. kPinned is technically dead... you shouldn't be using that for anything; however, there seems to be a hack that puts pinned objects to sleep on initialization. If you really want your objects to start asleep, use kStartInactive.

Whew... Now that we've got generic stuff out of the way, I'm not sure what specifics we're talking about :?
Image
User avatar
Tsar Hoikas
Councilor of Technical Direction
 
Posts: 1798
Joined: Fri Nov 16, 2007 9:45 pm
Location: South Georgia

Re: Physics bugs under -2000

Postby Sirius » Tue Feb 21, 2012 11:12 am

Ok, always good to know about these damn physics. Thank you to explain this to me.

Right now, the only issue is with markers below 2000, so that's not a real problem. I thought it might worth finding a better solution for kickables but my knowledge of C++ and Plasma is quite limited.

Tsar Hoikas wrote:Never animate a static physical. The result of that operation is undefined. It might work now, but it also might not later.
The object I was speaking about was in an Age on Complete Chronicles. I mentioned it because this part of the code didn't seem to have changed from MOUL to PotS. Since the Age itself is a converted Age from another Plasma version, that's not so amazing it missed kPinned. And trust me, I always avoid to animate physics at all.

Well, since it doesn't really seem to matter anyway, I guess there is no point in continuing this thread.
It seems you also have biggest troubles with physics currently ;)
User avatar
Sirius
 
Posts: 957
Joined: Mon Jul 26, 2010 4:46 am
Location: France


Return to Plasma Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron