]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix GCC 11 warns: use uninitialized in R_CanSeeBox
authorbones_was_here <bones_was_here@xa.org.au>
Sat, 11 Jun 2022 05:16:30 +0000 (15:16 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 20 Sep 2022 18:10:12 +0000 (04:10 +1000)
Introduced in 8ab339588b127e88e27bfa08f6eccbf9400b51f9

Signed-off-by: bones_was_here <bones_was_here@xa.org.au>
gl_rmain.c

index f9bc7499d8a2eca54914a06de4efc1c1a81f213c..4a51bd2bc93596f394538b7152115eb54f37b14f 100644 (file)
@@ -3960,13 +3960,13 @@ qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t en
        if (BoxesOverlap(boxmins, boxmaxs, eyemins, eyemaxs))
                return true;
 
+       VectorCopy(eye, start);
        // try specific positions in the box first - note that these can be cached
        if (r_cullentities_trace_entityocclusion.integer)
        {
                for (i = 0; i < sizeof(positions) / sizeof(positions[0]); i++)
                {
                        trace_t trace;
-                       VectorCopy(eye, start);
                        end[0] = boxmins[0] + (boxmaxs[0] - boxmins[0]) * positions[i][0];
                        end[1] = boxmins[1] + (boxmaxs[1] - boxmins[1]) * positions[i][1];
                        end[2] = boxmins[2] + (boxmaxs[2] - boxmins[2]) * positions[i][2];
@@ -3977,8 +3977,13 @@ qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t en
                                return true;
                }
        }
-       else if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
-               return true;
+       else
+       {
+               // try center
+               VectorMAM(0.5f, boxmins, 0.5f, boxmaxs, end);
+               if (model->brush.TraceLineOfSight(model, start, end, padmins, padmaxs))
+                       return true;
+       }
 
        // try various random positions
        for (j = 0; j < numsamples; j++)