Fix T85301: Eevee does not respect collection instance offset for hair

This resulted in hair drawing with an offset if an instance_offset was
set.

note: Usually the instance_offset gets combined with the objects obmat
in 'make_duplis_collection' / 'make_dupli', see
> /* Combine collection offset and `obmat`. */
Using the resulting DupliObject->mat instead does include the
instance_offset, but this results in double-transforms (something that I
have not investigated further), so now reconstruct the correct matrix
from scratch.

Maniphest Tasks: T85301

Differential Revision: https://developer.blender.org/D10285
This commit is contained in:
Philipp Oeser 2021-02-02 12:54:38 +01:00
parent 1d77302fd9
commit 9e0c876aad
Notes: blender-bot 2023-02-14 11:21:40 +01:00
Referenced by issue #85301, Eevee does not respect collection instance offset for hair (when rendering as 'Path')
2 changed files with 14 additions and 2 deletions

View File

@ -20,6 +20,7 @@
* \ingroup draw_engine
*/
#include "DNA_collection_types.h"
#include "DNA_mesh_types.h"
#include "DNA_particle_types.h"
#include "DNA_view3d_types.h"
@ -141,7 +142,12 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part
float dupli_mat[4][4];
if ((dupli_parent != NULL) && (dupli_object != NULL)) {
if (dupli_object->type & OB_DUPLICOLLECTION) {
copy_m4_m4(dupli_mat, dupli_parent->obmat);
unit_m4(dupli_mat);
Collection *collection = dupli_parent->instance_collection;
if (collection != NULL) {
sub_v3_v3(dupli_mat[3], collection->instance_offset);
}
mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat);
}
else {
copy_m4_m4(dupli_mat, dupli_object->ob->obmat);

View File

@ -28,6 +28,7 @@
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "DNA_collection_types.h"
#include "DNA_customdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
@ -195,7 +196,12 @@ void DRW_hair_duplimat_get(Object *object,
if (psys) {
if ((dupli_parent != NULL) && (dupli_object != NULL)) {
if (dupli_object->type & OB_DUPLICOLLECTION) {
copy_m4_m4(dupli_mat, dupli_parent->obmat);
unit_m4(dupli_mat);
Collection *collection = dupli_parent->instance_collection;
if (collection != NULL) {
sub_v3_v3(dupli_mat[3], collection->instance_offset);
}
mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat);
}
else {
copy_m4_m4(dupli_mat, dupli_object->ob->obmat);