Add disable_jump to liquids and ladders (#7688)
[oweals/minetest.git] / src / collision.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "collision.h"
21 #include <cmath>
22 #include "mapblock.h"
23 #include "map.h"
24 #include "nodedef.h"
25 #include "gamedef.h"
26 #ifndef SERVER
27 #include "client/clientenvironment.h"
28 #endif
29 #include "serverenvironment.h"
30 #include "serverobject.h"
31 #include "util/timetaker.h"
32 #include "profiler.h"
33
34 // float error is 10 - 9.96875 = 0.03125
35 //#define COLL_ZERO 0.032 // broken unit tests
36 #define COLL_ZERO 0
37
38
39 struct NearbyCollisionInfo {
40         NearbyCollisionInfo(bool is_ul, bool is_obj, int bouncy,
41                         const v3s16 &pos, const aabb3f &box) :
42                 is_unloaded(is_ul),
43                 is_object(is_obj),
44                 bouncy(bouncy),
45                 position(pos),
46                 box(box)
47         {}
48
49         bool is_unloaded;
50         bool is_step_up = false;
51         bool is_object;
52         int bouncy;
53         v3s16 position;
54         aabb3f box;
55 };
56
57
58 // Helper function:
59 // Checks for collision of a moving aabbox with a static aabbox
60 // Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision
61 // The time after which the collision occurs is stored in dtime.
62 CollisionAxis axisAlignedCollision(
63                 const aabb3f &staticbox, const aabb3f &movingbox,
64                 const v3f &speed, f32 d, f32 *dtime)
65 {
66         //TimeTaker tt("axisAlignedCollision");
67
68         f32 xsize = (staticbox.MaxEdge.X - staticbox.MinEdge.X) - COLL_ZERO;     // reduce box size for solve collision stuck (flying sand)
69         f32 ysize = (staticbox.MaxEdge.Y - staticbox.MinEdge.Y); // - COLL_ZERO; // Y - no sense for falling, but maybe try later
70         f32 zsize = (staticbox.MaxEdge.Z - staticbox.MinEdge.Z) - COLL_ZERO;
71
72         aabb3f relbox(
73                         movingbox.MinEdge.X - staticbox.MinEdge.X,
74                         movingbox.MinEdge.Y - staticbox.MinEdge.Y,
75                         movingbox.MinEdge.Z - staticbox.MinEdge.Z,
76                         movingbox.MaxEdge.X - staticbox.MinEdge.X,
77                         movingbox.MaxEdge.Y - staticbox.MinEdge.Y,
78                         movingbox.MaxEdge.Z - staticbox.MinEdge.Z
79         );
80
81         if(speed.X > 0) // Check for collision with X- plane
82         {
83                 if (relbox.MaxEdge.X <= d) {
84                         *dtime = -relbox.MaxEdge.X / speed.X;
85                         if ((relbox.MinEdge.Y + speed.Y * (*dtime) < ysize) &&
86                                         (relbox.MaxEdge.Y + speed.Y * (*dtime) > COLL_ZERO) &&
87                                         (relbox.MinEdge.Z + speed.Z * (*dtime) < zsize) &&
88                                         (relbox.MaxEdge.Z + speed.Z * (*dtime) > COLL_ZERO))
89                                 return COLLISION_AXIS_X;
90                 }
91                 else if(relbox.MinEdge.X > xsize)
92                 {
93                         return COLLISION_AXIS_NONE;
94                 }
95         }
96         else if(speed.X < 0) // Check for collision with X+ plane
97         {
98                 if (relbox.MinEdge.X >= xsize - d) {
99                         *dtime = (xsize - relbox.MinEdge.X) / speed.X;
100                         if ((relbox.MinEdge.Y + speed.Y * (*dtime) < ysize) &&
101                                         (relbox.MaxEdge.Y + speed.Y * (*dtime) > COLL_ZERO) &&
102                                         (relbox.MinEdge.Z + speed.Z * (*dtime) < zsize) &&
103                                         (relbox.MaxEdge.Z + speed.Z * (*dtime) > COLL_ZERO))
104                                 return COLLISION_AXIS_X;
105                 }
106                 else if(relbox.MaxEdge.X < 0)
107                 {
108                         return COLLISION_AXIS_NONE;
109                 }
110         }
111
112         // NO else if here
113
114         if(speed.Y > 0) // Check for collision with Y- plane
115         {
116                 if (relbox.MaxEdge.Y <= d) {
117                         *dtime = -relbox.MaxEdge.Y / speed.Y;
118                         if ((relbox.MinEdge.X + speed.X * (*dtime) < xsize) &&
119                                         (relbox.MaxEdge.X + speed.X * (*dtime) > COLL_ZERO) &&
120                                         (relbox.MinEdge.Z + speed.Z * (*dtime) < zsize) &&
121                                         (relbox.MaxEdge.Z + speed.Z * (*dtime) > COLL_ZERO))
122                                 return COLLISION_AXIS_Y;
123                 }
124                 else if(relbox.MinEdge.Y > ysize)
125                 {
126                         return COLLISION_AXIS_NONE;
127                 }
128         }
129         else if(speed.Y < 0) // Check for collision with Y+ plane
130         {
131                 if (relbox.MinEdge.Y >= ysize - d) {
132                         *dtime = (ysize - relbox.MinEdge.Y) / speed.Y;
133                         if ((relbox.MinEdge.X + speed.X * (*dtime) < xsize) &&
134                                         (relbox.MaxEdge.X + speed.X * (*dtime) > COLL_ZERO) &&
135                                         (relbox.MinEdge.Z + speed.Z * (*dtime) < zsize) &&
136                                         (relbox.MaxEdge.Z + speed.Z * (*dtime) > COLL_ZERO))
137                                 return COLLISION_AXIS_Y;
138                 }
139                 else if(relbox.MaxEdge.Y < 0)
140                 {
141                         return COLLISION_AXIS_NONE;
142                 }
143         }
144
145         // NO else if here
146
147         if(speed.Z > 0) // Check for collision with Z- plane
148         {
149                 if (relbox.MaxEdge.Z <= d) {
150                         *dtime = -relbox.MaxEdge.Z / speed.Z;
151                         if ((relbox.MinEdge.X + speed.X * (*dtime) < xsize) &&
152                                         (relbox.MaxEdge.X + speed.X * (*dtime) > COLL_ZERO) &&
153                                         (relbox.MinEdge.Y + speed.Y * (*dtime) < ysize) &&
154                                         (relbox.MaxEdge.Y + speed.Y * (*dtime) > COLL_ZERO))
155                                 return COLLISION_AXIS_Z;
156                 }
157                 //else if(relbox.MinEdge.Z > zsize)
158                 //{
159                 //      return COLLISION_AXIS_NONE;
160                 //}
161         }
162         else if(speed.Z < 0) // Check for collision with Z+ plane
163         {
164                 if (relbox.MinEdge.Z >= zsize - d) {
165                         *dtime = (zsize - relbox.MinEdge.Z) / speed.Z;
166                         if ((relbox.MinEdge.X + speed.X * (*dtime) < xsize) &&
167                                         (relbox.MaxEdge.X + speed.X * (*dtime) > COLL_ZERO) &&
168                                         (relbox.MinEdge.Y + speed.Y * (*dtime) < ysize) &&
169                                         (relbox.MaxEdge.Y + speed.Y * (*dtime) > COLL_ZERO))
170                                 return COLLISION_AXIS_Z;
171                 }
172                 //else if(relbox.MaxEdge.Z < 0)
173                 //{
174                 //      return COLLISION_AXIS_NONE;
175                 //}
176         }
177
178         return COLLISION_AXIS_NONE;
179 }
180
181 // Helper function:
182 // Checks if moving the movingbox up by the given distance would hit a ceiling.
183 bool wouldCollideWithCeiling(
184                 const std::vector<NearbyCollisionInfo> &cinfo,
185                 const aabb3f &movingbox,
186                 f32 y_increase, f32 d)
187 {
188         //TimeTaker tt("wouldCollideWithCeiling");
189
190         assert(y_increase >= 0);        // pre-condition
191
192         for (const auto &it : cinfo) {
193                 const aabb3f &staticbox = it.box;
194                 if ((movingbox.MaxEdge.Y - d <= staticbox.MinEdge.Y) &&
195                                 (movingbox.MaxEdge.Y + y_increase > staticbox.MinEdge.Y) &&
196                                 (movingbox.MinEdge.X < staticbox.MaxEdge.X) &&
197                                 (movingbox.MaxEdge.X > staticbox.MinEdge.X) &&
198                                 (movingbox.MinEdge.Z < staticbox.MaxEdge.Z) &&
199                                 (movingbox.MaxEdge.Z > staticbox.MinEdge.Z))
200                         return true;
201         }
202
203         return false;
204 }
205
206 static inline void getNeighborConnectingFace(const v3s16 &p,
207         const NodeDefManager *nodedef, Map *map, MapNode n, int v, int *neighbors)
208 {
209         MapNode n2 = map->getNodeNoEx(p);
210         if (nodedef->nodeboxConnects(n, n2, v))
211                 *neighbors |= v;
212 }
213
214 collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
215                 f32 pos_max_d, const aabb3f &box_0,
216                 f32 stepheight, f32 dtime,
217                 v3f *pos_f, v3f *speed_f,
218                 v3f accel_f, ActiveObject *self,
219                 bool collideWithObjects)
220 {
221         static bool time_notification_done = false;
222         Map *map = &env->getMap();
223         //TimeTaker tt("collisionMoveSimple");
224         ScopeProfiler sp(g_profiler, "collisionMoveSimple avg", SPT_AVG);
225
226         collisionMoveResult result;
227
228         /*
229                 Calculate new velocity
230         */
231         if (dtime > 0.5f) {
232                 if (!time_notification_done) {
233                         time_notification_done = true;
234                         infostream << "collisionMoveSimple: maximum step interval exceeded,"
235                                         " lost movement details!"<<std::endl;
236                 }
237                 dtime = 0.5f;
238         } else {
239                 time_notification_done = false;
240         }
241         *speed_f += accel_f * dtime;
242
243         // If there is no speed, there are no collisions
244         if (speed_f->getLength() == 0)
245                 return result;
246
247         // Limit speed for avoiding hangs
248         speed_f->Y = rangelim(speed_f->Y, -5000, 5000);
249         speed_f->X = rangelim(speed_f->X, -5000, 5000);
250         speed_f->Z = rangelim(speed_f->Z, -5000, 5000);
251
252         /*
253                 Collect node boxes in movement range
254         */
255         std::vector<NearbyCollisionInfo> cinfo;
256         {
257         //TimeTaker tt2("collisionMoveSimple collect boxes");
258         ScopeProfiler sp2(g_profiler, "collisionMoveSimple collect boxes avg", SPT_AVG);
259
260         v3f newpos_f = *pos_f + *speed_f * dtime;
261         v3f minpos_f(
262                 MYMIN(pos_f->X, newpos_f.X),
263                 MYMIN(pos_f->Y, newpos_f.Y) + 0.01f * BS, // bias rounding, player often at +/-n.5
264                 MYMIN(pos_f->Z, newpos_f.Z)
265         );
266         v3f maxpos_f(
267                 MYMAX(pos_f->X, newpos_f.X),
268                 MYMAX(pos_f->Y, newpos_f.Y),
269                 MYMAX(pos_f->Z, newpos_f.Z)
270         );
271         v3s16 min = floatToInt(minpos_f + box_0.MinEdge, BS) - v3s16(1, 1, 1);
272         v3s16 max = floatToInt(maxpos_f + box_0.MaxEdge, BS) + v3s16(1, 1, 1);
273
274         bool any_position_valid = false;
275
276         v3s16 p;
277         for (p.X = min.X; p.X <= max.X; p.X++)
278         for (p.Y = min.Y; p.Y <= max.Y; p.Y++)
279         for (p.Z = min.Z; p.Z <= max.Z; p.Z++) {
280                 bool is_position_valid;
281                 MapNode n = map->getNodeNoEx(p, &is_position_valid);
282
283                 if (is_position_valid && n.getContent() != CONTENT_IGNORE) {
284                         // Object collides into walkable nodes
285
286                         any_position_valid = true;
287                         const NodeDefManager *nodedef = gamedef->getNodeDefManager();
288                         const ContentFeatures &f = nodedef->get(n);
289
290                         if (!f.walkable)
291                                 continue;
292
293                         int n_bouncy_value = itemgroup_get(f.groups, "bouncy");
294
295                         int neighbors = 0;
296                         if (f.drawtype == NDT_NODEBOX &&
297                                 f.node_box.type == NODEBOX_CONNECTED) {
298                                 v3s16 p2 = p;
299
300                                 p2.Y++;
301                                 getNeighborConnectingFace(p2, nodedef, map, n, 1, &neighbors);
302
303                                 p2 = p;
304                                 p2.Y--;
305                                 getNeighborConnectingFace(p2, nodedef, map, n, 2, &neighbors);
306
307                                 p2 = p;
308                                 p2.Z--;
309                                 getNeighborConnectingFace(p2, nodedef, map, n, 4, &neighbors);
310
311                                 p2 = p;
312                                 p2.X--;
313                                 getNeighborConnectingFace(p2, nodedef, map, n, 8, &neighbors);
314
315                                 p2 = p;
316                                 p2.Z++;
317                                 getNeighborConnectingFace(p2, nodedef, map, n, 16, &neighbors);
318
319                                 p2 = p;
320                                 p2.X++;
321                                 getNeighborConnectingFace(p2, nodedef, map, n, 32, &neighbors);
322                         }
323                         std::vector<aabb3f> nodeboxes;
324                         n.getCollisionBoxes(gamedef->ndef(), &nodeboxes, neighbors);
325
326                         // Calculate float position only once
327                         v3f posf = intToFloat(p, BS);
328                         for (auto box : nodeboxes) {
329                                 box.MinEdge += posf;
330                                 box.MaxEdge += posf;
331                                 cinfo.emplace_back(false, false, n_bouncy_value, p, box);
332                         }
333                 } else {
334                         // Collide with unloaded nodes (position invalid) and loaded
335                         // CONTENT_IGNORE nodes (position valid)
336                         aabb3f box = getNodeBox(p, BS);
337                         cinfo.emplace_back(true, false, 0, p, box);
338                 }
339         }
340
341         // Do not move if world has not loaded yet, since custom node boxes
342         // are not available for collision detection.
343         // This also intentionally occurs in the case of the object being positioned
344         // solely on loaded CONTENT_IGNORE nodes, no matter where they come from.
345         if (!any_position_valid) {
346                 *speed_f = v3f(0, 0, 0);
347                 return result;
348         }
349
350         } // tt2
351
352         if(collideWithObjects)
353         {
354                 ScopeProfiler sp2(g_profiler, "collisionMoveSimple objects avg", SPT_AVG);
355                 //TimeTaker tt3("collisionMoveSimple collect object boxes");
356
357                 /* add object boxes to cinfo */
358
359                 std::vector<ActiveObject*> objects;
360 #ifndef SERVER
361                 ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
362                 if (c_env != 0) {
363                         // Calculate distance by speed, add own extent and 1.5m of tolerance
364                         f32 distance = speed_f->getLength() * dtime +
365                                 box_0.getExtent().getLength() + 1.5f * BS;
366                         std::vector<DistanceSortedActiveObject> clientobjects;
367                         c_env->getActiveObjects(*pos_f, distance, clientobjects);
368
369                         for (auto &clientobject : clientobjects) {
370                                 // Do collide with everything but itself and the parent CAO
371                                 if (!self || (self != clientobject.obj &&
372                                                 self != clientobject.obj->getParent())) {
373                                         objects.push_back((ActiveObject*) clientobject.obj);
374                                 }
375                         }
376                 }
377                 else
378 #endif
379                 {
380                         ServerEnvironment *s_env = dynamic_cast<ServerEnvironment*>(env);
381                         if (s_env != NULL) {
382                                 // Calculate distance by speed, add own extent and 1.5m of tolerance
383                                 f32 distance = speed_f->getLength() * dtime +
384                                         box_0.getExtent().getLength() + 1.5f * BS;
385                                 std::vector<u16> s_objects;
386                                 s_env->getObjectsInsideRadius(s_objects, *pos_f, distance);
387
388                                 for (u16 obj_id : s_objects) {
389                                         ServerActiveObject *current = s_env->getActiveObject(obj_id);
390
391                                         if (!self || (self != current &&
392                                                         self != current->getParent())) {
393                                                 objects.push_back((ActiveObject*)current);
394                                         }
395                                 }
396                         }
397                 }
398
399                 for (std::vector<ActiveObject*>::const_iterator iter = objects.begin();
400                                 iter != objects.end(); ++iter) {
401                         ActiveObject *object = *iter;
402
403                         if (object) {
404                                 aabb3f object_collisionbox;
405                                 if (object->getCollisionBox(&object_collisionbox) &&
406                                                 object->collideWithObjects()) {
407                                         cinfo.emplace_back(false, true, 0, v3s16(), object_collisionbox);
408                                 }
409                         }
410                 }
411         } //tt3
412
413         /*
414                 Collision detection
415         */
416
417         /*
418                 Collision uncertainty radius
419                 Make it a bit larger than the maximum distance of movement
420         */
421         f32 d = pos_max_d * 1.1f;
422         // A fairly large value in here makes moving smoother
423         //f32 d = 0.15*BS;
424
425         // This should always apply, otherwise there are glitches
426         assert(d > pos_max_d);  // invariant
427
428         int loopcount = 0;
429
430         while(dtime > BS * 1e-10f) {
431                 //TimeTaker tt3("collisionMoveSimple dtime loop");
432                 ScopeProfiler sp2(g_profiler, "collisionMoveSimple dtime loop avg", SPT_AVG);
433
434                 // Avoid infinite loop
435                 loopcount++;
436                 if (loopcount >= 100) {
437                         warningstream << "collisionMoveSimple: Loop count exceeded, aborting to avoid infiniite loop" << std::endl;
438                         break;
439                 }
440
441                 aabb3f movingbox = box_0;
442                 movingbox.MinEdge += *pos_f;
443                 movingbox.MaxEdge += *pos_f;
444
445                 CollisionAxis nearest_collided = COLLISION_AXIS_NONE;
446                 f32 nearest_dtime = dtime;
447                 int nearest_boxindex = -1;
448
449                 /*
450                         Go through every nodebox, find nearest collision
451                 */
452                 for (u32 boxindex = 0; boxindex < cinfo.size(); boxindex++) {
453                         const NearbyCollisionInfo &box_info = cinfo[boxindex];
454                         // Ignore if already stepped up this nodebox.
455                         if (box_info.is_step_up)
456                                 continue;
457
458                         // Find nearest collision of the two boxes (raytracing-like)
459                         f32 dtime_tmp;
460                         CollisionAxis collided = axisAlignedCollision(box_info.box,
461                                         movingbox, *speed_f, d, &dtime_tmp);
462
463                         if (collided == -1 || dtime_tmp >= nearest_dtime)
464                                 continue;
465
466                         nearest_dtime = dtime_tmp;
467                         nearest_collided = collided;
468                         nearest_boxindex = boxindex;
469                 }
470
471                 if (nearest_collided == COLLISION_AXIS_NONE) {
472                         // No collision with any collision box.
473                         *pos_f += *speed_f * dtime;
474                         dtime = 0;  // Set to 0 to avoid "infinite" loop due to small FP numbers
475                 } else {
476                         // Otherwise, a collision occurred.
477                         NearbyCollisionInfo &nearest_info = cinfo[nearest_boxindex];
478                         const aabb3f& cbox = nearest_info.box;
479                         // Check for stairs.
480                         bool step_up = (nearest_collided != COLLISION_AXIS_Y) && // must not be Y direction
481                                         (movingbox.MinEdge.Y < cbox.MaxEdge.Y) &&
482                                         (movingbox.MinEdge.Y + stepheight > cbox.MaxEdge.Y) &&
483                                         (!wouldCollideWithCeiling(cinfo, movingbox,
484                                                         cbox.MaxEdge.Y - movingbox.MinEdge.Y,
485                                                         d));
486
487                         // Get bounce multiplier
488                         float bounce = -(float)nearest_info.bouncy / 100.0f;
489
490                         // Move to the point of collision and reduce dtime by nearest_dtime
491                         if (nearest_dtime < 0) {
492                                 // Handle negative nearest_dtime (can be caused by the d allowance)
493                                 if (!step_up) {
494                                         if (nearest_collided == COLLISION_AXIS_X)
495                                                 pos_f->X += speed_f->X * nearest_dtime;
496                                         if (nearest_collided == COLLISION_AXIS_Y)
497                                                 pos_f->Y += speed_f->Y * nearest_dtime;
498                                         if (nearest_collided == COLLISION_AXIS_Z)
499                                                 pos_f->Z += speed_f->Z * nearest_dtime;
500                                 }
501                         } else {
502                                 *pos_f += *speed_f * nearest_dtime;
503                                 dtime -= nearest_dtime;
504                         }
505
506                         bool is_collision = true;
507                         if (nearest_info.is_unloaded)
508                                 is_collision = false;
509
510                         CollisionInfo info;
511                         if (nearest_info.is_object)
512                                 info.type = COLLISION_OBJECT;
513                         else
514                                 info.type = COLLISION_NODE;
515
516                         info.node_p = nearest_info.position;
517                         info.old_speed = *speed_f;
518                         info.plane = nearest_collided;
519
520                         // Set the speed component that caused the collision to zero
521                         if (step_up) {
522                                 // Special case: Handle stairs
523                                 nearest_info.is_step_up = true;
524                                 is_collision = false;
525                         } else if (nearest_collided == COLLISION_AXIS_X) {
526                                 if (fabs(speed_f->X) > BS * 3)
527                                         speed_f->X *= bounce;
528                                 else
529                                         speed_f->X = 0;
530                                 result.collides = true;
531                         } else if (nearest_collided == COLLISION_AXIS_Y) {
532                                 if(fabs(speed_f->Y) > BS * 3)
533                                         speed_f->Y *= bounce;
534                                 else
535                                         speed_f->Y = 0;
536                                 result.collides = true;
537                         } else if (nearest_collided == COLLISION_AXIS_Z) {
538                                 if (fabs(speed_f->Z) > BS * 3)
539                                         speed_f->Z *= bounce;
540                                 else
541                                         speed_f->Z = 0;
542                                 result.collides = true;
543                         }
544
545                         info.new_speed = *speed_f;
546                         if (info.new_speed.getDistanceFrom(info.old_speed) < 0.1f * BS)
547                                 is_collision = false;
548
549                         if (is_collision) {
550                                 info.axis = nearest_collided;
551                                 result.collisions.push_back(info);
552                         }
553                 }
554         }
555
556         /*
557                 Final touches: Check if standing on ground, step up stairs.
558         */
559         aabb3f box = box_0;
560         box.MinEdge += *pos_f;
561         box.MaxEdge += *pos_f;
562         for (const auto &box_info : cinfo) {
563                 const aabb3f &cbox = box_info.box;
564
565                 /*
566                         See if the object is touching ground.
567
568                         Object touches ground if object's minimum Y is near node's
569                         maximum Y and object's X-Z-area overlaps with the node's
570                         X-Z-area.
571
572                         Use 0.15*BS so that it is easier to get on a node.
573                 */
574                 if (cbox.MaxEdge.X - d > box.MinEdge.X && cbox.MinEdge.X + d < box.MaxEdge.X &&
575                                 cbox.MaxEdge.Z - d > box.MinEdge.Z &&
576                                 cbox.MinEdge.Z + d < box.MaxEdge.Z) {
577                         if (box_info.is_step_up) {
578                                 pos_f->Y += cbox.MaxEdge.Y - box.MinEdge.Y;
579                                 box = box_0;
580                                 box.MinEdge += *pos_f;
581                                 box.MaxEdge += *pos_f;
582                         }
583                         if (std::fabs(cbox.MaxEdge.Y - box.MinEdge.Y) < 0.15f * BS) {
584                                 result.touching_ground = true;
585
586                                 if (box_info.is_object)
587                                         result.standing_on_object = true;
588                         }
589                 }
590         }
591
592         return result;
593 }