From 4d32652851b7af5ea6f70f05fca3cedd11808b1b Mon Sep 17 00:00:00 2001 From: clayjohn Date: Tue, 7 Apr 2020 10:35:58 -0700 Subject: [PATCH] Avoid material rebind when using skeleton --- drivers/gles2/rasterizer_scene_gles2.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index c0ba93db6a2..e5215ea7203 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -2451,16 +2451,16 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, RasterizerStorageGLES2::Skeleton *skeleton = storage->skeleton_owner.getornull(e->instance->skeleton); if (skeleton != prev_skeleton) { - - if (skeleton) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, true); - state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, storage->config.use_skeleton_software); - } else { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, false); - state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, false); + if ((prev_skeleton == NULL) != (skeleton == NULL)) { + if (skeleton) { + state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, true); + state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, storage->config.use_skeleton_software); + } else { + state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, false); + state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, false); + } + rebind = true; } - - rebind = true; } if (e->owner != prev_owner || e->geometry != prev_geometry || skeleton != prev_skeleton) {