Mesh mesh object- mesh geopattern auto ptr b_ob data ptr auto geopatte

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Mesh *mesh = object->mesh;
/* geopattern */
{
auto ptr = b_ob.data().ptr;
auto geopattern_prop = RNA_struct_find_property(&ptr, "[\"Geopattern\"]");
if (geopattern_prop) {
if (RNA_property_type(geopattern_prop) == PROP_STRING) {
size_t len = RNA_property_string_length(&ptr, geopattern_prop);
std::unique_ptr<char[]> memory(new char[len + 1]);
RNA_property_string_get(&ptr, geopattern_prop, memory.get());
ustring link(memory.get());
bool found = false;
for (auto &obj_it : scene->objects) {
if (obj_it->name != link) {
continue;
}
if (!obj_it->mesh) {
fprintf(stderr, "Geopattern: candidate %s has no mesh!\n", obj_it->name.c_str());
continue;
}
found = true;
obj_it->mesh->geopattern_settings.object = object;
mesh->geopattern_settings.level = obj_it->mesh->geopattern_settings.level + 1;
printf("Geopattern: linking object \"%s\" to object \"%s\"\n", object->name.c_str(), obj_it->name.c_str());
}
if (!found) {
fprintf(stderr, "Geopattern(Object %s): Object %s wasn't found!\n", b_ob.name().c_str(), link.c_str());
fprintf(stderr, "Possible reasons: the object does not exist in scene or it is not child of %s\n", b_ob.name().c_str());
}
}else {
fprintf(stderr, "Geopattern: type of Geopattern property is not string!\n");
}
}
}