Best way to implement a cape.

adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Best way to implement a cape.

Post by adtpg »

Greetings,

I've recently started intergrating a cape with cloth physics on a human model. The cloth is a 10*10 patch (created with the softbodyhelper) attached to the human's shoulders via anchor points. When the character moves the cape follows very well.

However, when adding kinematic geometry on him for the cape to collide with, like for the torso / legs / head, the cape just ignores it. Putting the cape in 'space' the same kinematic objects are able to collide with it, just not when its on the body.

Has anyone have any input on what might be the issue?

Thanks!
adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Re: Best way to implement a cape.

Post by adtpg »

Seems to be an issue of tunneling for sure. I tried changing the player collision from capsules to boxes just to see if that helped any, and accidentally left in a large scale value. However, when running the cloth collided fine with it (just not sized correctly). Resizing the boxes to a smaller value made the cloth not work again. I noticed a few other forum topics on this issue, gonna see what I can dig up.
adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Re: Best way to implement a cape.

Post by adtpg »

So going back to the case of a large box, I changed to make just my player have one box shape for now for his torso, but expanded it on a scale of 10 or so. When starting the app the cape mostly rest against the box, but then after moving, the cape no longer even tries to collide with it, more or less just ignoring the collision. Any idea what might be up here? Both of my objects have the

setActivationState(DISABLE_DEACTIVATION);

flag on, perhaps im missing something else?

Thanks
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Best way to implement a cape.

Post by Erwin Coumans »

You should never use DISABLE_DEACTIVATION, it is an internal setting.

For static objects that never move use mass=0. Otherwise use kinematic object, see CcdPhysicsDemo or the Bullet_User_Manual.pdf
Hope this helps,
Erwin
adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Re: Best way to implement a cape.

Post by adtpg »

Hmm, I got rid of the DISABLE_DEACTIVATION flag, no dice.

I tried the following

cape = mass 2.

1. have my box set to have a mass of 0, and is flagged as kinematic.
Result : Starts off fine, then stops caring about collision.

2. have my box set to have a mass of 20, and is flagged as kinematic.
Result : Starts off fine, then stops caring about collision.

3. have my box set to have a mass of 20, and is flagged as kinematic and disable deac.
Result : Starts off fine, then stops caring about collision.

4. have my box set to have a mass of 0, and is flagged as kinematic and disable deac.
Result : Starts off fine, then stops caring about collision.

What's weird is that in all cases, its sometimes starts caring about the collision again, and will do so for another 10-15 seconds before stopping again.

When its not colliding (although it should be), nothing is being sent into the near callback via the dispatcher.

Also here are various flags im using on the cape:

<Param Name="ResolutionX" Type="int" Value="10" />
<Param Name="ResolutionY" Type="int" Value="10" />

<Param Name="m_kLST" Type="float" Value="1" />
<Param Name="m_kAST" Type="float" Value="1" />
<Param Name="m_kVST" Type="float" Value="1" />

<Param Name="kVCF" Type="float" Value="1" />
<Param Name="kDG" Type="float" Value="0" />
<Param Name="kLF" Type="float" Value="0" />
<Param Name="kDP" Type="float" Value="0" />
<Param Name="kPR" Type="float" Value="0" />
<Param Name="kVC" Type="float" Value="0" />
<Param Name="kDF" Type="float" Value="0.2" />
<Param Name="kMT" Type="float" Value="0" />
<Param Name="kCHR" Type="float" Value="1.0" />
<Param Name="kKHR" Type="float" Value="0.9" />
<Param Name="kSHR" Type="float" Value="1.0" />
<Param Name="kAHR" Type="float" Value="1.0" />
<Param Name="kSRHR_CL" Type="float" Value="0.1" />
<Param Name="kSKHR_CL" Type="float" Value="1" />
<Param Name="kSSHR_CL" Type="float" Value="0.5" />
<Param Name="kSR_SPLT_CL" Type="float" Value="0.5" />
<Param Name="kSK_SPLT_CL" Type="float" Value="0.5" />
<Param Name="kSS_SPLT_CL" Type="float" Value="0.5" />
<Param Name="maxvolume" Type="float" Value="1" />
<Param Name="timescale" Type="float" Value="1" />
<Param Name="viterations" Type="int" Value="4" />
<Param Name="piterations" Type="int" Value="32" />
<Param Name="diterations" Type="int" Value="0" />
<Param Name="citerations" Type="int" Value="4" />

Sadly there's not much in the manual for rigid to soft collisions so im not sure what I'm missing. I'm going to try collision clusters here shortly and will report anything I get.

Thanks for the reply!
adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Re: Best way to implement a cape.

Post by adtpg »

Erwin Coumans wrote:You should never use DISABLE_DEACTIVATION, it is an internal setting.

For static objects that never move use mass=0. Otherwise use kinematic object, see CcdPhysicsDemo or the Bullet_User_Manual.pdf
Hope this helps,
Erwin
Also, maybe im misunderstanding this, from the manual:
Kinematic Bodies

If you plan to animate or move static objects, you should flag them as kinematic. Also disable the sleeping/deactivation for them during the animation. This means Bullet dynamics world will get the new worldtransform from the btMotionState every simulation frame.

body->setCollisionFlags( body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
body->setActivationState(DISABLE_DEACTIVATION);

???
adtpg
Posts: 10
Joined: Wed Aug 05, 2009 6:50 pm

Re: Best way to implement a cape.

Post by adtpg »

Hmm, I'm starting to think that somehow the collision shapes aren't moving correctly or something.

Very strange, the debug drawing of the objects show they are moving (cape and human model shapes), but the collision only seems to be occuring around the initialization of the object.