Fix T42294: Bullet rigidbody point cache reading was using uninitialized
key values for velocity.
This commit is contained in:
parent
133f79e449
commit
f7dedbc3ce
Notes:
blender-bot
2023-02-14 10:42:29 +01:00
Referenced by issue #42294, Bullet Physic Rigid Body Updates In Viewport Playback, Object Using Constraints (Loc,Rot) Breaks One Frame In To Animation When Rendering, But Viewport Playback Updates Correctly Referenced by issue #40017, Wrong Motion Blur with Rigid Body Simulation / Point Cache
|
@ -378,7 +378,7 @@ void free_keyed_keys(struct ParticleSystem *psys);
|
|||
void psys_free_particles(struct ParticleSystem *psys);
|
||||
void psys_free_children(struct ParticleSystem *psys);
|
||||
|
||||
void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, int velocity);
|
||||
void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity);
|
||||
void psys_vec_rot_to_face(struct DerivedMesh *dm, struct ParticleData *pa, float vec[3]);
|
||||
void psys_mat_hair_to_object(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[4][4]);
|
||||
void psys_mat_hair_to_global(struct Object *ob, struct DerivedMesh *dm, short from, struct ParticleData *pa, float hairmat[4][4]);
|
||||
|
|
|
@ -1043,7 +1043,7 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4,
|
|||
return value;
|
||||
}
|
||||
|
||||
void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, int velocity)
|
||||
void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, ParticleKey *result, bool velocity)
|
||||
{
|
||||
float t[4];
|
||||
|
||||
|
@ -1073,7 +1073,6 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic
|
|||
}
|
||||
|
||||
|
||||
|
||||
typedef struct ParticleInterpolationData {
|
||||
HairKey *hkey[2];
|
||||
|
||||
|
|
|
@ -1043,8 +1043,6 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
|
|||
{
|
||||
RigidBodyWorld *rbw = rb_v;
|
||||
Object *ob = NULL;
|
||||
ParticleKey keys[4];
|
||||
float dfra;
|
||||
|
||||
if (rbw->objects)
|
||||
ob = rbw->objects[index];
|
||||
|
@ -1053,6 +1051,11 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
|
|||
RigidBodyOb *rbo = ob->rigidbody_object;
|
||||
|
||||
if (rbo->type == RBO_TYPE_ACTIVE) {
|
||||
ParticleKey keys[4];
|
||||
ParticleKey result;
|
||||
float dfra;
|
||||
|
||||
memset(keys, 0, sizeof(keys));
|
||||
|
||||
copy_v3_v3(keys[1].co, rbo->pos);
|
||||
copy_qt_qt(keys[1].rot, rbo->orn);
|
||||
|
@ -1062,16 +1065,17 @@ static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, fl
|
|||
memcpy(keys[2].rot, data + 3, 4 * sizeof(float));
|
||||
}
|
||||
else {
|
||||
BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2);
|
||||
BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2);
|
||||
}
|
||||
|
||||
dfra = cfra2 - cfra1;
|
||||
|
||||
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, keys, 1);
|
||||
interp_qt_qtqt(keys->rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
|
||||
/* note: keys[0] and keys[3] unused for type < 1 (crappy) */
|
||||
psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &result, true);
|
||||
interp_qt_qtqt(result.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra);
|
||||
|
||||
copy_v3_v3(rbo->pos, keys->co);
|
||||
copy_qt_qt(rbo->orn, keys->rot);
|
||||
copy_v3_v3(rbo->pos, result.co);
|
||||
copy_qt_qt(rbo->orn, result.rot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue