projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more physics shapes
[carveJwlIkooP6JGAAIwe30JlM.git]
/
character.h
diff --git
a/character.h
b/character.h
index 5ce456f24a1648493bd2056aa57156c4efac401b..3421d3a4df9117a648f5446182cf08811c3fa73a 100644
(file)
--- a/
character.h
+++ b/
character.h
@@
-441,11
+441,14
@@
void character_final_pose( struct character *ch, v3f cog,
tilt = vg_clampf(cog[2], -1.0f, 1.0f) * 0.3f;
v4f rz; m4x3f tr;
tilt = vg_clampf(cog[2], -1.0f, 1.0f) * 0.3f;
v4f rz; m4x3f tr;
- q_axis_angle( rz, (v3f){0.0f,0.0f,1.0f}, -cog[0]*0.
6
f );
+ q_axis_angle( rz, (v3f){0.0f,0.0f,1.0f}, -cog[0]*0.
3
f );
q_m3x3( rz, tr );
q_m3x3( rz, tr );
- v3_copy( (v3f){0.0f,dip,tilt}, tr[3] );
+ m3x3_identity( tr );
+ //v3_copy( (v3f){0.0f,dip,tilt}, tr[3] );
+ v3_copy( cog, tr[3] );
- m4x3_mulv( tr, pose->b0, npose.b0 );
+ v3_muladd( pose->b0, tr[3], (v3f){0.85f,1.0f,1.0f}, npose.b0 );
+ //m4x3_mulv( tr, pose->b0, npose.b0 );
m4x3_mulv( tr, pose->b1, npose.b1 );
m4x3_mulv( tr, pose->p, npose.p );
m4x3_mulv( tr, pose->pl, npose.pl );
m4x3_mulv( tr, pose->b1, npose.b1 );
m4x3_mulv( tr, pose->p, npose.p );
m4x3_mulv( tr, pose->pl, npose.pl );
@@
-553,8
+556,7
@@
static void character_testpose( struct character *ch, float t )
m4x3_identity( ch->matrices[k_chpart_wf] );
}
m4x3_identity( ch->matrices[k_chpart_wf] );
}
-static float *player_cam_pos(void);
-static void character_draw( struct character *ch, float temp )
+static void character_draw( struct character *ch, float temp, m4x3f camera )
{
shader_character_use();
shader_character_uPv( vg_pv );
{
shader_character_use();
shader_character_uPv( vg_pv );
@@
-562,7
+564,7
@@
static void character_draw( struct character *ch, float temp )
vg_tex2d_bind( &tex_pallet, 0 );
shader_character_uTexMain( 0 );
shader_character_uOpacity( temp );
vg_tex2d_bind( &tex_pallet, 0 );
shader_character_uTexMain( 0 );
shader_character_uOpacity( temp );
- shader_character_uCamera(
player_cam_pos()
);
+ shader_character_uCamera(
camera[3]
);
shader_link_standard_ub( _shader_character.id, 2 );
glEnable( GL_CULL_FACE );
shader_link_standard_ub( _shader_character.id, 2 );
glEnable( GL_CULL_FACE );
@@
-822,8
+824,7
@@
static void character_ragdoll_copypose( struct character *ch, v3f v )
m4x3_mulv( ch->matrices[i], rb->delta, rb->co );
m3x3_q( ch->matrices[i], rb->q );
v3_copy( v, rb->v );
m4x3_mulv( ch->matrices[i], rb->delta, rb->co );
m3x3_q( ch->matrices[i], rb->q );
v3_copy( v, rb->v );
- v3_zero( rb->I );
- rb->manifold_count = 0; /* ? */
+ v3_zero( rb->w );
rb_update_transform( rb );
}
rb_update_transform( rb );
}
@@
-881,11
+882,14
@@
static void character_debug_ragdoll( struct character *ch )
static void character_ragdoll_iter( struct character *ch )
{
static void character_ragdoll_iter( struct character *ch )
{
+ rb_solver_reset();
+
for( int i=0; i<PART_COUNT; i++ )
{
for( int i=0; i<PART_COUNT; i++ )
{
- rb_manifold_reset( &ch->ragdoll[i] );
rb_build_manifold_terrain( &ch->ragdoll[i] );
rb_build_manifold_terrain( &ch->ragdoll[i] );
+ /* TODO: Cars, piece-to-piece collision */
+#if 0
u32 colliders[16];
int len = bh_select( &world.bhcubes, ch->ragdoll[i].bbx_world,
colliders, 16 );
u32 colliders[16];
int len = bh_select( &world.bhcubes, ch->ragdoll[i].bbx_world,
colliders, 16 );
@@
-893,22
+897,25
@@
static void character_ragdoll_iter( struct character *ch )
for( int j=0; j<len; j++ )
rb_build_manifold_rb_static( &ch->ragdoll[i],
&world.temp_rbs[colliders[j]] );
for( int j=0; j<len; j++ )
rb_build_manifold_rb_static( &ch->ragdoll[i],
&world.temp_rbs[colliders[j]] );
+#endif
}
}
+ rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
+
v3f rv;
v3f rv;
- float shoe_vel[2];
+ float shoe_vel[2]
= {0.0f,0.0f}
;
for( int i=0; i<2; i++ )
if( ch->shoes[i] )
shoe_vel[i] = v3_length( ch->ragdoll[i].v );
for( int i=0; i<2; i++ )
if( ch->shoes[i] )
shoe_vel[i] = v3_length( ch->ragdoll[i].v );
-
- for( int i=0; i<20; i++ )
+
+ /* This used to be 20 iterations */
+ for( int i=0; i<5; i++ )
{
float const k_springfactor = 1.0f/20.0f;
{
float const k_springfactor = 1.0f/20.0f;
-
- for( int j=0; j<PART_COUNT; j++ )
- rb_constraint_manifold( &ch->ragdoll[j] );
-
+
+ rb_solve_contacts( rb_contact_buffer, rb_contact_count );
+
for( int j=0; j<vg_list_size(rd_joints); j++ )
{
struct rd_joint *joint = &rd_joints[j];
for( int j=0; j<vg_list_size(rd_joints); j++ )
{
struct rd_joint *joint = &rd_joints[j];
@@
-956,7
+963,7
@@
static void character_ragdoll_iter( struct character *ch )
v3_copy( src->co, dst->co );
v3_copy( src->v, dst->v );
v3_copy( src->q, dst->q );
v3_copy( src->co, dst->co );
v3_copy( src->v, dst->v );
v3_copy( src->q, dst->q );
- v3_copy( src->
I, dst->I
);
+ v3_copy( src->
w, dst->w
);
}
}
}
}
}
}