Fix T40566: Light instances disappears in rendered viewport (Blender Internal)
This is just another issue caused by convertblender overwriting the object matrix at the time of creating render object. What's even worse here is that original matrix is not stored for the lamps, only lamp_matrix*view_matrix is stored. For sure we can combine lar->co and lar->mat back to mat4, multiply by the inverse view matrix and get object matrix, but this is not suitable for the viewport render because every viewport rotation will accumulate the error. For now let's store worldspace lamp matrix in the LampRen structure and use it when rotating the scene.
This commit is contained in:
@@ -595,7 +595,9 @@ typedef struct LampRen {
|
||||
float imat[3][3];
|
||||
float spottexfac;
|
||||
float sh_invcampos[3], sh_zfac; /* sh_= spothalo */
|
||||
|
||||
|
||||
float lampmat[4][4]; /* worls space lamp matrix, used for scene rotation */
|
||||
|
||||
float mat[3][3]; /* 3x3 part from lampmat x viewmat */
|
||||
float area[8][3], areasize;
|
||||
|
||||
|
||||
@@ -3650,6 +3650,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
mul_m4_m4m4(mat, re->viewmat, ob->obmat);
|
||||
invert_m4_m4(ob->imat, mat);
|
||||
|
||||
copy_m4_m4(lar->lampmat, ob->obmat);
|
||||
copy_m3_m4(lar->mat, mat);
|
||||
copy_m3_m4(lar->imat, ob->imat);
|
||||
|
||||
|
||||
@@ -329,9 +329,9 @@ void env_rotate_scene(Render *re, float mat[4][4], int do_rotate)
|
||||
|
||||
/* copy from add_render_lamp */
|
||||
if (do_rotate == 1)
|
||||
mul_m4_m4m4(tmpmat, re->viewmat, go->ob->obmat);
|
||||
mul_m4_m4m4(tmpmat, re->viewmat, lar->lampmat);
|
||||
else
|
||||
mul_m4_m4m4(tmpmat, re->viewmat_orig, go->ob->obmat);
|
||||
mul_m4_m4m4(tmpmat, re->viewmat_orig, lar->lampmat);
|
||||
invert_m4_m4(go->ob->imat, tmpmat);
|
||||
|
||||
copy_m3_m4(lar->mat, tmpmat);
|
||||
|
||||
Reference in New Issue
Block a user