fixed missing automatic reflection cubemaps in the last scene
authorJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 16 Dec 2022 23:17:18 +0000 (01:17 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Fri, 16 Dec 2022 23:17:18 +0000 (01:17 +0200)
src/3dengfx/src/3dengfx/3dscene.cpp

index de49021..e2f896d 100644 (file)
@@ -532,35 +532,23 @@ bool Scene::render_all_cube_maps(unsigned long msec) const {
        while(iter != objects.end()) {
                Object *obj = *iter++;
 
-               Texture *env;
                Material *mat = obj->get_material_ptr();
+               Texture *env = mat->get_texture(TEXTYPE_ENVMAP);
+               if(!env || env->get_type() != TEX_CUBE) continue;
+
                RenderParams rp = obj->get_render_params();
                if(rp.hidden) continue;
 
                // if it is marked as a non-automatically updated reflection map, skip it.
-               if(!mat->auto_refl) {
-                       continue;
+               if(mat->auto_refl) {
+                       if(mat->auto_refl_upd > 1 && frame_count % mat->auto_refl_upd) continue;
+               } else {
+                       if(!first_render) continue;
                }
 
-               // if auto-reflect is set for updating every nth frame,
-               // and this is not one of them, skip it.
-               if(mat->auto_refl_upd > 1 && frame_count % mat->auto_refl_upd) {
-                       continue;
-               }
-               
-               // if auto-reflect is set to update only during the first frame,
-               // and this is not the first frame, skip it.
-               if(mat->auto_refl_upd == 0 && !first_render) {
-                       continue;
-               }
-               
                // ... otherwise, update the reflection in the cubemap.
-               if((env = mat->get_texture(TEXTYPE_ENVMAP))) {
-                       if(env->get_type() == TEX_CUBE) {
-                               did_some = true;
-                               render_cube_map(obj, msec);
-                       }
-               }
+               did_some = true;
+               render_cube_map(obj, msec);
        }
 
        return did_some;