Workbench: Fixed SegFault

In more complex models the object color uniform data is freed before rendered.
We should copy it to local data. but for now we redirected it to a
constant.
This commit is contained in:
Jeroen Bakker
2018-04-18 10:43:03 +02:00
parent d9051c46fd
commit ed72eedd07
2 changed files with 5 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ static struct {
struct GPUShader *solid_sh;
} e_data = {NULL};
const float SOLID_FLAT_DEFAULT_COLOR[3] = {1.0, 1.0, 1.0};
/* Functions */
@@ -94,7 +95,7 @@ static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
WORKBENCH_StorageList *stl = data->stl;
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
const float* color = BKE_collection_engine_property_value_get_float_array(props, "object_color");
// const float* color = BKE_collection_engine_property_value_get_float_array(props, "object_color");
if (!DRW_object_is_renderable(ob))
return;
@@ -107,7 +108,7 @@ static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
/* Solid */
grp = DRW_shgroup_create(e_data.solid_sh, psl->solid_pass);
DRW_shgroup_uniform_vec3(grp, "color", color, 1);
DRW_shgroup_uniform_vec3(grp, "color", SOLID_FLAT_DEFAULT_COLOR, 1);
DRW_shgroup_call_add(grp, geom, ob->obmat);
}
}

View File

@@ -44,6 +44,7 @@ static struct {
struct GPUShader *solid_sh;
} e_data = {NULL};
const float SOLID_STUDIO_DEFAULT_COLOR[3] = {1.0, 1.0, 1.0};
/* Functions */
@@ -107,7 +108,7 @@ static void workbench_solid_studio_cache_populate(void *vedata, Object *ob)
/* Solid */
grp = DRW_shgroup_create(e_data.solid_sh, psl->solid_pass);
DRW_shgroup_uniform_vec3(grp, "color", color, 1);
DRW_shgroup_uniform_vec3(grp, "color", SOLID_STUDIO_DEFAULT_COLOR, 1);
DRW_shgroup_call_add(grp, geom, ob->obmat);
}
}