Fix crash drawing non-mesh geometry

This commit is contained in:
Campbell Barton 2017-06-12 14:43:19 +10:00
parent c2f6ca313e
commit 12bd960df9

@ -211,8 +211,8 @@ typedef struct DRWCall {
float obmat[4][4];
Batch *geometry;
Mesh *mesh; /* Optional. */
Object *ob; /* Optionnal */
Object *ob; /* Optional */
ID *ob_data; /* Optional. */
} DRWCall;
typedef struct DRWCallGenerate {
@ -878,7 +878,7 @@ void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Batch *geom, Object *
copy_m4_m4(call->obmat, ob->obmat);
call->geometry = geom;
call->mesh = ob->data;
call->ob_data = ob->data;
BLI_addtail(&shgroup->calls, call);
}
@ -1649,13 +1649,19 @@ static void draw_geometry_execute(DRWShadingGroup *shgroup, Batch *geom)
}
}
static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*obmat)[4], Mesh *me)
static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*obmat)[4], ID *ob_data)
{
float *texcoloc = NULL;
float *texcosize = NULL;
if (me != NULL) {
BKE_mesh_texspace_get_reference(me, NULL, &texcoloc, NULL, &texcosize);
if (ob_data != NULL) {
switch (GS(ob_data->name)) {
case OB_MESH:
BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, NULL, &texcosize);
/* TODO, curve, metaball? */
default:
break;
}
}
draw_geometry_prepare(shgroup, obmat, texcoloc, texcosize);
@ -1792,7 +1798,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
GPU_SELECT_LOAD_IF_PICKSEL(call);
if (call->head.type == DRW_CALL_SINGLE) {
draw_geometry(shgroup, call->geometry, call->obmat, call->mesh);
draw_geometry(shgroup, call->geometry, call->obmat, call->ob_data);
}
else {
BLI_assert(call->head.type == DRW_CALL_GENERATE);