Translated using Weblate (Japanese)
[oweals/minetest.git] / src / collision.cpp
index c759f20c066bfc2f2bf8ba1ea272b37eecc25a18..adb6970f5fc4f5d31791c46621027e3f0ce26c3f 100644 (file)
@@ -176,7 +176,7 @@ bool wouldCollideWithCeiling(
 
        for(std::vector<aabb3f>::const_iterator
                        i = staticboxes.begin();
-                       i != staticboxes.end(); i++)
+                       i != staticboxes.end(); ++i)
        {
                const aabb3f& staticbox = *i;
                if((movingbox.MaxEdge.Y - d <= staticbox.MinEdge.Y) &&
@@ -265,7 +265,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                        std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(gamedef->ndef());
                        for(std::vector<aabb3f>::iterator
                                        i = nodeboxes.begin();
-                                       i != nodeboxes.end(); i++)
+                                       i != nodeboxes.end(); ++i)
                        {
                                aabb3f box = *i;
                                box.MinEdge += v3f(x, y, z)*BS;
@@ -318,8 +318,9 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                        ServerEnvironment *s_env = dynamic_cast<ServerEnvironment*>(env);
                        if (s_env != 0) {
                                f32 distance = speed_f.getLength();
-                               std::set<u16> s_objects = s_env->getObjectsInsideRadius(pos_f,distance * 1.5);
-                               for (std::set<u16>::iterator iter = s_objects.begin(); iter != s_objects.end(); iter++) {
+                               std::vector<u16> s_objects;
+                               s_env->getObjectsInsideRadius(s_objects, pos_f, distance * 1.5);
+                               for (std::vector<u16>::iterator iter = s_objects.begin(); iter != s_objects.end(); ++iter) {
                                        ServerActiveObject *current = s_env->getActiveObject(*iter);
                                        if ((self == 0) || (self != current)) {
                                                objects.push_back((ActiveObject*)current);
@@ -457,7 +458,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
                                pos_f += speed_f * nearest_dtime;
                                dtime -= nearest_dtime;
                        }
-                       
+
                        bool is_collision = true;
                        if(is_unloaded[nearest_boxindex])
                                is_collision = false;
@@ -560,76 +561,3 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
 
        return result;
 }
-
-#if 0
-// This doesn't seem to work and isn't used
-collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
-               f32 pos_max_d, const aabb3f &box_0,
-               f32 stepheight, f32 dtime,
-               v3f &pos_f, v3f &speed_f, v3f &accel_f)
-{
-       //TimeTaker tt("collisionMovePrecise");
-    ScopeProfiler sp(g_profiler, "collisionMovePrecise avg", SPT_AVG);
-       
-       collisionMoveResult final_result;
-
-       // If there is no speed, there are no collisions
-       if(speed_f.getLength() == 0)
-               return final_result;
-
-       // Don't allow overly huge dtime
-       if(dtime > 2.0)
-               dtime = 2.0;
-
-       f32 dtime_downcount = dtime;
-
-       u32 loopcount = 0;
-       do
-       {
-               loopcount++;
-
-               // Maximum time increment (for collision detection etc)
-               // time = distance / speed
-               f32 dtime_max_increment = 1.0;
-               if(speed_f.getLength() != 0)
-                       dtime_max_increment = pos_max_d / speed_f.getLength();
-
-               // Maximum time increment is 10ms or lower
-               if(dtime_max_increment > 0.01)
-                       dtime_max_increment = 0.01;
-
-               f32 dtime_part;
-               if(dtime_downcount > dtime_max_increment)
-               {
-                       dtime_part = dtime_max_increment;
-                       dtime_downcount -= dtime_part;
-               }
-               else
-               {
-                       dtime_part = dtime_downcount;
-                       /*
-                               Setting this to 0 (no -=dtime_part) disables an infinite loop
-                               when dtime_part is so small that dtime_downcount -= dtime_part
-                               does nothing
-                       */
-                       dtime_downcount = 0;
-               }
-
-               collisionMoveResult result = collisionMoveSimple(map, gamedef,
-                               pos_max_d, box_0, stepheight, dtime_part,
-                               pos_f, speed_f, accel_f);
-
-               if(result.touching_ground)
-                       final_result.touching_ground = true;
-               if(result.collides)
-                       final_result.collides = true;
-               if(result.collides_xz)
-                       final_result.collides_xz = true;
-               if(result.standing_on_unloaded)
-                       final_result.standing_on_unloaded = true;
-       }
-       while(dtime_downcount > 0.001);
-
-       return final_result;
-}
-#endif