+ std::vector<aabb3f> cboxes;
+ std::vector<bool> is_unloaded;
+ std::vector<bool> is_step_up;
+ std::vector<bool> is_object;
+ std::vector<int> bouncy_values;
+ std::vector<v3s16> node_positions;
+ {
+ //TimeTaker tt2("collisionMoveSimple collect boxes");
+ ScopeProfiler sp(g_profiler, "collisionMoveSimple collect boxes avg", SPT_AVG);
+
+ v3s16 oldpos_i = floatToInt(pos_f, BS);
+ v3s16 newpos_i = floatToInt(pos_f + speed_f * dtime, BS);
+ s16 min_x = MYMIN(oldpos_i.X, newpos_i.X) + (box_0.MinEdge.X / BS) - 1;
+ s16 min_y = MYMIN(oldpos_i.Y, newpos_i.Y) + (box_0.MinEdge.Y / BS) - 1;
+ s16 min_z = MYMIN(oldpos_i.Z, newpos_i.Z) + (box_0.MinEdge.Z / BS) - 1;
+ s16 max_x = MYMAX(oldpos_i.X, newpos_i.X) + (box_0.MaxEdge.X / BS) + 1;
+ s16 max_y = MYMAX(oldpos_i.Y, newpos_i.Y) + (box_0.MaxEdge.Y / BS) + 1;
+ s16 max_z = MYMAX(oldpos_i.Z, newpos_i.Z) + (box_0.MaxEdge.Z / BS) + 1;
+
+ for(s16 x = min_x; x <= max_x; x++)
+ for(s16 y = min_y; y <= max_y; y++)
+ for(s16 z = min_z; z <= max_z; z++)
+ {
+ v3s16 p(x,y,z);
+
+ bool is_position_valid;
+ MapNode n = map->getNodeNoEx(p, &is_position_valid);
+
+ if (is_position_valid) {
+ // Object collides into walkable nodes
+
+ const ContentFeatures &f = gamedef->getNodeDefManager()->get(n);
+ if(f.walkable == false)
+ continue;
+ int n_bouncy_value = itemgroup_get(f.groups, "bouncy");
+
+ std::vector<aabb3f> nodeboxes = n.getCollisionBoxes(gamedef->ndef());
+ for(std::vector<aabb3f>::iterator
+ i = nodeboxes.begin();
+ i != nodeboxes.end(); i++)
+ {
+ aabb3f box = *i;
+ box.MinEdge += v3f(x, y, z)*BS;
+ box.MaxEdge += v3f(x, y, z)*BS;
+ cboxes.push_back(box);
+ is_unloaded.push_back(false);
+ is_step_up.push_back(false);
+ bouncy_values.push_back(n_bouncy_value);
+ node_positions.push_back(p);
+ is_object.push_back(false);
+ }
+ }
+ else {
+ // Collide with unloaded nodes
+ aabb3f box = getNodeBox(p, BS);
+ cboxes.push_back(box);
+ is_unloaded.push_back(true);
+ is_step_up.push_back(false);
+ bouncy_values.push_back(0);
+ node_positions.push_back(p);
+ is_object.push_back(false);
+ }
+ }
+ } // tt2
+
+ if(collideWithObjects)
+ {
+ ScopeProfiler sp(g_profiler, "collisionMoveSimple objects avg", SPT_AVG);
+ //TimeTaker tt3("collisionMoveSimple collect object boxes");
+
+ /* add object boxes to cboxes */
+
+
+ std::vector<ActiveObject*> objects;
+#ifndef SERVER
+ ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
+ if (c_env != 0) {
+ f32 distance = speed_f.getLength();
+ std::vector<DistanceSortedActiveObject> clientobjects;
+ c_env->getActiveObjects(pos_f,distance * 1.5,clientobjects);
+ for (size_t i=0; i < clientobjects.size(); i++) {
+ if ((self == 0) || (self != clientobjects[i].obj)) {
+ objects.push_back((ActiveObject*)clientobjects[i].obj);
+ }
+ }
+ }
+ else
+#endif
+ {
+ ServerEnvironment *s_env = dynamic_cast<ServerEnvironment*>(env);
+ if (s_env != 0) {
+ f32 distance = speed_f.getLength();
+ 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);
+ }
+ }
+ }
+ }
+
+ for (std::vector<ActiveObject*>::const_iterator iter = objects.begin();
+ iter != objects.end(); ++iter) {
+ ActiveObject *object = *iter;
+
+ if (object != NULL) {
+ aabb3f object_collisionbox;
+ if (object->getCollisionBox(&object_collisionbox) &&
+ object->collideWithObjects()) {
+ cboxes.push_back(object_collisionbox);
+ is_unloaded.push_back(false);
+ is_step_up.push_back(false);
+ bouncy_values.push_back(0);
+ node_positions.push_back(v3s16(0,0,0));
+ is_object.push_back(true);
+ }
+ }
+ }
+ } //tt3
+
+ assert(cboxes.size() == is_unloaded.size()); // post-condition
+ assert(cboxes.size() == is_step_up.size()); // post-condition
+ assert(cboxes.size() == bouncy_values.size()); // post-condition
+ assert(cboxes.size() == node_positions.size()); // post-condition
+ assert(cboxes.size() == is_object.size()); // post-condition