Commit: 0f3bc636c828bcbaa79952375d86a222f4873ecb
Author: Clément Foucault
Date:   Wed Feb 14 17:52:19 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB0f3bc636c828bcbaa79952375d86a222f4873ecb

GWN: Allow drawing instances without batch_instancing

===================================================================

M       intern/gawain/src/gwn_batch.c

===================================================================

diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c
index 677158e09df..9cd5400f144 100644
--- a/intern/gawain/src/gwn_batch.c
+++ b/intern/gawain/src/gwn_batch.c
@@ -202,7 +202,8 @@ static void 
Batch_update_program_bindings_instancing(Gwn_Batch* batch, Gwn_Batch
                glDisableVertexAttribArray(a_idx);
 
        create_bindings(batch, batch->interface, 0, false);
-       create_bindings(batch_instancing, batch->interface, instance_first, 
true);
+       if (batch_instancing)
+               create_bindings(batch_instancing, batch->interface, 
instance_first, true);
 
        batch->program_dirty = false;
        }
@@ -386,6 +387,10 @@ void GWN_batch_draw_stupid(Gwn_Batch* batch, int v_first, 
int v_count)
 
 void GWN_batch_draw_stupid_instanced(Gwn_Batch* batch_instanced, Gwn_Batch* 
batch_instancing, int instance_first, int instance_count)
        {
+#if TRUST_NO_ONE
+       // batch_instancing can be null if the number of instances is specified.
+       assert(batch_instancing != NULL || instance_count != 0);
+#endif
        if (batch_instanced->vao_id)
                glBindVertexArray(batch_instanced->vao_id);
        else
@@ -394,10 +399,8 @@ void GWN_batch_draw_stupid_instanced(Gwn_Batch* 
batch_instanced, Gwn_Batch* batc
        if (batch_instanced->program_dirty)
                Batch_update_program_bindings_instancing(batch_instanced, 
batch_instancing, instance_first);
 
-       Gwn_VertBuf* verts = batch_instancing->verts[0];
-
        if (instance_count == 0)
-               instance_count = verts->vertex_ct;
+               instance_count = batch_instancing->verts[0]->vertex_ct;
 
        if (batch_instanced->elem)
                {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to