From 2f32a75d2e2afc22e7e170c2506455010d063ce8 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 Mar 2019 12:23:03 -0300 Subject: Skeletons can now choose between using local or world coords for processing, fixes #26468 --- drivers/gles3/rasterizer_scene_gles3.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'drivers/gles3/rasterizer_scene_gles3.cpp') diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index e645e39f3f..ac2c100f7b 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2044,7 +2044,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ int current_blend_mode = -1; int prev_shading = -1; - RID prev_skeleton; + RasterizerStorageGLES3::Skeleton *prev_skeleton = NULL; state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS, true); //by default unshaded (easier to set) @@ -2058,7 +2058,10 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ RenderList::Element *e = p_elements[i]; RasterizerStorageGLES3::Material *material = e->material; - RID skeleton = e->instance->skeleton; + RasterizerStorageGLES3::Skeleton *skeleton = NULL; + if (e->instance->skeleton.is_valid()) { + skeleton = storage->skeleton_owner.getornull(e->instance->skeleton); + } bool rebind = first; @@ -2205,15 +2208,14 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ } if (prev_skeleton != skeleton) { - if (prev_skeleton.is_valid() != skeleton.is_valid()) { - state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON, skeleton.is_valid()); + if ((prev_skeleton == NULL) != (skeleton == NULL)) { + state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON, skeleton != NULL); rebind = true; } - if (skeleton.is_valid()) { - RasterizerStorageGLES3::Skeleton *sk = storage->skeleton_owner.getornull(skeleton); + if (skeleton) { glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); - glBindTexture(GL_TEXTURE_2D, sk->texture); + glBindTexture(GL_TEXTURE_2D, skeleton->texture); } } @@ -2240,6 +2242,11 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ _set_cull(e->sort_key & RenderList::SORT_KEY_MIRROR_FLAG, e->sort_key & RenderList::SORT_KEY_CULL_DISABLED_FLAG, p_reverse_cull); + if (skeleton) { + state.scene_shader.set_uniform(SceneShaderGLES3::SKELETON_TRANSFORM, skeleton->world_transform); + state.scene_shader.set_uniform(SceneShaderGLES3::SKELETON_IN_WORLD_COORDS, skeleton->use_world_transform); + } + state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, e->instance->transform); _render_geometry(e); -- cgit v1.2.3