Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-11-11 14:54:01 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-11-11 16:45:01 +0300
commit80f5a5a8aa12594fb724e9ba45185e13c914f7dd (patch)
tree78b436001cbde4afa5482783e5fc2d1d99f446ea
parent38430c384a29b8fc900eef839c2dd307d0d96ea4 (diff)
Fix T101270: Object Info > Random not unique for nested instances and curves
This random number is intended to be unique for every instance, however for some cases with more than one level of nesting this was failing. This also affected curves after they were refactored to use geometry sets. For simple cases the random number is the same as before, however for more complex nesting it will be different than before, changing the render result.
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 5efd44c620b..3d35cea1e93 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -87,6 +87,9 @@ struct DupliContext {
Object *obedit;
Scene *scene;
+ /** Root parent object at the scene level. */
+ Object *root_object;
+ /** Immediate parent object in the context. */
Object *object;
float space_mat[4][4];
/**
@@ -138,6 +141,7 @@ static void init_context(DupliContext *r_ctx,
r_ctx->scene = scene;
r_ctx->collection = nullptr;
+ r_ctx->root_object = ob;
r_ctx->object = ob;
r_ctx->obedit = OBEDIT_FROM_OBACT(ob);
r_ctx->instance_stack = &instance_stack;
@@ -264,8 +268,9 @@ static DupliObject *make_dupli(const DupliContext *ctx,
dob->no_draw = true;
}
- /* Random number.
- * The logic here is designed to match Cycles. */
+ /* Random number per instance.
+ * The root object in the scene, persistent ID up to the instance object, and the instance object
+ * name together result in a unique random number. */
dob->random_id = BLI_hash_string(dob->ob->id.name + 2);
if (dob->persistent_id[0] != INT_MAX) {
@@ -277,8 +282,8 @@ static DupliObject *make_dupli(const DupliContext *ctx,
dob->random_id = BLI_hash_int_2d(dob->random_id, 0);
}
- if (ctx->object != ob) {
- dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->object->id.name + 2));
+ if (ctx->root_object != ob) {
+ dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->root_object->id.name + 2));
}
return dob;