clean up rigidbody
[carveJwlIkooP6JGAAIwe30JlM.git] / player_model.h
index a067b033d2a9c290aba32db78f83665ba7972f8c..e1e43a5770c48b338f43f24881a954fe94037d03 100644 (file)
@@ -153,6 +153,21 @@ static void character_draw( struct character *ch, float temp, m4x3f camera ){}
 static void character_init_ragdoll_joints( struct character *ch ){}
 static void character_init_ragdoll( struct character *ch ){}
 static void character_ragdoll_go( struct character *ch, v3f pos ){}
+
+static void character_mimic_ragdoll( struct character *ch )
+{
+   for( int i=0; i<ch->ragdoll_count; i++ )
+   {
+      struct ragdoll_part *part = &ch->ragdoll[i];
+      m4x3f offset;
+      m3x3_identity(offset);
+      v3_negate( part->offset, offset[3] );
+      m4x3_mul( part->rb.to_world, offset, ch->sk.final_mtx[part->bone_id] );
+   }
+
+   skeleton_apply_inverses( &ch->sk );
+}
+
 static void character_ragdoll_copypose( struct character *ch, v3f v )
 {
    for( int i=0; i<ch->ragdoll_count; i++ )
@@ -229,7 +244,7 @@ static void character_ragdoll_iter( struct character *ch )
          struct ragdoll_part *pj = &ch->ragdoll[j];
          struct skeleton_bone *bj = &ch->sk.bones[pj->bone_id];
 
-         if( pj->parent != 0xffffffff )
+         if( pj->parent != 0xffffffff && pj->use_limits )
          {
             struct ragdoll_part *pp = &ch->ragdoll[pj->parent];
             struct skeleton_bone *bp = &ch->sk.bones[pp->bone_id];
@@ -241,10 +256,7 @@ static void character_ragdoll_iter( struct character *ch )
 
             rb_constraint_position( &pj->rb, lca, &pp->rb, lcb );
 
-            if( pj->use_limits )
-            {
-               rb_constraint_limits( &pj->rb, lca, &pp->rb, lcb, pj->limits );
-            }
+            rb_constraint_limits( &pj->rb, lca, &pp->rb, lcb, pj->limits );
          }
       }
    }