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:
authorAlexander Gavrilov <angavrilov@gmail.com>2022-09-30 18:54:26 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-09-30 20:01:57 +0300
commit554afabf7580d60cc1990bb9df9d9940cb1fb1c3 (patch)
treefdd40672265c948b600482d3b17d9667dbf17844 /intern/cycles
parent42eda155df3b77a49c4c1aa3ddcc681e43771111 (diff)
Attribute Node: refactor lookup to remove duplication between engines.
Currently lookup of Object and Instancer attributes is completely duplicated between Cycles, Eevee and Eevee Next. This is bad design, so this patch aims to deduplicate it by introducing a common API in blenkernel. In case of Cycles this requires certain hacks, but according to Brecht it is planned to be rewritten later for more direct access to internal Blender data anyway. Differential Revision: https://developer.blender.org/D16117
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/blender/CMakeLists.txt1
-rw-r--r--intern/cycles/blender/object.cpp73
2 files changed, 12 insertions, 62 deletions
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index 666b0077a72..ceb024ba5e7 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -7,6 +7,7 @@ set(INC
../../mikktspace
../../../source/blender/makesdna
../../../source/blender/makesrna
+ ../../../source/blender/blenkernel
../../../source/blender/blenlib
../../../source/blender/gpu
../../../source/blender/render
diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp
index 109408c354d..8a3c1136104 100644
--- a/intern/cycles/blender/object.cpp
+++ b/intern/cycles/blender/object.cpp
@@ -23,6 +23,8 @@
#include "util/log.h"
#include "util/task.h"
+#include "BKE_duplilist.h"
+
CCL_NAMESPACE_BEGIN
/* Utilities */
@@ -353,79 +355,26 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
return object;
}
-/* This function mirrors drw_uniform_property_lookup in draw_instance_data.cpp */
-static bool lookup_property(BL::ID b_id, const string &name, float4 *r_value)
-{
- PointerRNA ptr;
- PropertyRNA *prop;
-
- if (!RNA_path_resolve(&b_id.ptr, name.c_str(), &ptr, &prop)) {
- return false;
- }
-
- if (prop == NULL) {
- return false;
- }
+extern "C" DupliObject *rna_hack_DepsgraphObjectInstance_dupli_object_get(PointerRNA *ptr);
- PropertyType type = RNA_property_type(prop);
- int arraylen = RNA_property_array_length(&ptr, prop);
-
- if (arraylen == 0) {
- float value;
-
- if (type == PROP_FLOAT)
- value = RNA_property_float_get(&ptr, prop);
- else if (type == PROP_INT)
- value = static_cast<float>(RNA_property_int_get(&ptr, prop));
- else
- return false;
-
- *r_value = make_float4(value, value, value, 1.0f);
- return true;
- }
- else if (type == PROP_FLOAT && arraylen <= 4) {
- *r_value = make_float4(0.0f, 0.0f, 0.0f, 1.0f);
- RNA_property_float_get_array(&ptr, prop, &r_value->x);
- return true;
- }
-
- return false;
-}
-
-/* This function mirrors drw_uniform_attribute_lookup in draw_instance_data.cpp */
static float4 lookup_instance_property(BL::DepsgraphObjectInstance &b_instance,
const string &name,
bool use_instancer)
{
- string idprop_name = string_printf("[\"%s\"]", name.c_str());
- float4 value;
+ ::Object *ob = (::Object *)b_instance.object().ptr.data;
+ ::DupliObject *dupli = nullptr;
+ ::Object *dupli_parent = nullptr;
/* If requesting instance data, check the parent particle system and object. */
if (use_instancer && b_instance.is_instance()) {
- BL::ParticleSystem b_psys = b_instance.particle_system();
-
- if (b_psys) {
- if (lookup_property(b_psys.settings(), idprop_name, &value) ||
- lookup_property(b_psys.settings(), name, &value)) {
- return value;
- }
- }
- if (lookup_property(b_instance.parent(), idprop_name, &value) ||
- lookup_property(b_instance.parent(), name, &value)) {
- return value;
- }
+ dupli = rna_hack_DepsgraphObjectInstance_dupli_object_get(&b_instance.ptr);
+ dupli_parent = (::Object *)b_instance.parent().ptr.data;
}
- /* Check the object and mesh. */
- BL::Object b_ob = b_instance.object();
- BL::ID b_data = b_ob.data();
-
- if (lookup_property(b_ob, idprop_name, &value) || lookup_property(b_ob, name, &value) ||
- lookup_property(b_data, idprop_name, &value) || lookup_property(b_data, name, &value)) {
- return value;
- }
+ float4 value;
+ BKE_object_dupli_find_rgba_attribute(ob, dupli, dupli_parent, name.c_str(), &value.x);
- return zero_float4();
+ return value;
}
bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object)