mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Add Appgurueu Integrations and Fixes
This commit is contained in:
parent
42fdaa9838
commit
f602479316
@ -7,6 +7,7 @@
|
|||||||
#include "irrMath.h"
|
#include "irrMath.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
@ -32,6 +33,9 @@ class vector3d
|
|||||||
//! Constructor with the same value for all elements
|
//! Constructor with the same value for all elements
|
||||||
explicit constexpr vector3d(T n) :
|
explicit constexpr vector3d(T n) :
|
||||||
X(n), Y(n), Z(n) {}
|
X(n), Y(n), Z(n) {}
|
||||||
|
//! Array - vector conversion
|
||||||
|
constexpr vector3d(const std::array<T, 3>& arr) :
|
||||||
|
X(arr[0]), Y(arr[1]), Z(arr[2]) {}
|
||||||
|
|
||||||
// operators
|
// operators
|
||||||
|
|
||||||
@ -181,6 +185,26 @@ class vector3d
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::array<T, 3> toArray() const {
|
||||||
|
return { X, Y, Z };
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3d<T> min(const T min_component) const {
|
||||||
|
return vector3d<T>(
|
||||||
|
std::min(X, min_component),
|
||||||
|
std::min(Y, min_component),
|
||||||
|
std::min(Z, min_component)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector3d<T> max(const T max_component) const {
|
||||||
|
return vector3d<T>(
|
||||||
|
std::max(X, max_component),
|
||||||
|
std::max(Y, max_component),
|
||||||
|
std::max(Z, max_component)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//! Get length of the vector.
|
//! Get length of the vector.
|
||||||
T getLength() const { return core::squareroot(X * X + Y * Y + Z * Z); }
|
T getLength() const { return core::squareroot(X * X + Y * Y + Z * Z); }
|
||||||
|
|
||||||
|
@ -281,13 +281,15 @@ static void add_object_boxes(Environment *env,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calculate distance by speed, add own extent and 1.5m of tolerance
|
const f32 tolerance = 1.5f * BS; // TODO increase tolerance
|
||||||
const f32 distance = speed_f.getLength() * dtime +
|
|
||||||
box_0.getExtent().getLength() + 1.5f * BS;
|
|
||||||
|
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
|
ClientEnvironment *c_env = dynamic_cast<ClientEnvironment*>(env);
|
||||||
if (c_env) {
|
if (c_env) {
|
||||||
|
// Calculate distance by speed, add own extent and 1.5m of tolerance
|
||||||
|
const f32 distance = speed_f.getLength() * dtime +
|
||||||
|
box_0.getExtent().getLength() + 1.5f * BS;
|
||||||
|
|
||||||
std::vector<DistanceSortedActiveObject> clientobjects;
|
std::vector<DistanceSortedActiveObject> clientobjects;
|
||||||
c_env->getActiveObjects(pos_f, distance, clientobjects);
|
c_env->getActiveObjects(pos_f, distance, clientobjects);
|
||||||
|
|
||||||
@ -326,9 +328,14 @@ static void add_object_boxes(Environment *env,
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Calculate distance by speed, add own extent and tolerance
|
||||||
|
const v3f movement = speed_f * dtime;
|
||||||
|
const v3f min = pos_f + box_0.MinEdge - v3f(tolerance) + movement.min(0);
|
||||||
|
const v3f max = pos_f + box_0.MaxEdge + v3f(tolerance) + movement.max(0);
|
||||||
|
|
||||||
// nothing is put into this vector
|
// nothing is put into this vector
|
||||||
std::vector<ServerActiveObject*> s_objects;
|
std::vector<ServerActiveObject*> s_objects;
|
||||||
s_env->getObjectsInsideRadius(s_objects, pos_f, distance, include_obj_cb);
|
s_env->getObjectsInArea(s_objects, aabb3f(min, max), include_obj_cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,7 @@ void ActiveObjectMgr::clearIf(const std::function<bool(ServerActiveObject *, u16
|
|||||||
continue;
|
continue;
|
||||||
if (cb(it.second.get(), it.first)) {
|
if (cb(it.second.get(), it.first)) {
|
||||||
// Remove reference from m_active_objects
|
// Remove reference from m_active_objects
|
||||||
m_spatial_map.remove(it.first, it.second->getBasePosition());
|
removeObject(it.first);
|
||||||
m_active_objects.remove(it.first);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,10 +94,10 @@ bool ActiveObjectMgr::registerObject(std::unique_ptr<ServerActiveObject> obj)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectpos_over_limit(obj->getBasePosition())) {
|
const v3f pos = obj->getBasePosition();
|
||||||
v3f p = obj->getBasePosition();
|
if (objectpos_over_limit(pos)) {
|
||||||
warningstream << "Server::ActiveObjectMgr::addActiveObjectRaw(): "
|
warningstream << "Server::ActiveObjectMgr::addActiveObjectRaw(): "
|
||||||
<< "object position (" << p.X << "," << p.Y << "," << p.Z
|
<< "object position (" << pos.X << "," << pos.Y << "," << pos.Z
|
||||||
<< ") outside maximum range" << std::endl;
|
<< ") outside maximum range" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerActiveObject::setBasePosition(const v3f &pos) {
|
void ServerActiveObject::setBasePosition(const v3f &pos) {
|
||||||
if(getEnv())
|
bool changed = m_base_position != pos;
|
||||||
|
if (changed && getEnv())
|
||||||
getEnv()->updateObjectPosition(getId(), m_base_position, pos);
|
getEnv()->updateObjectPosition(getId(), m_base_position, pos);
|
||||||
m_base_position = pos;
|
m_base_position = pos;
|
||||||
}
|
}
|
||||||
|
@ -1871,10 +1871,12 @@ void ServerEnvironment::getSelectedActiveObjects(
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
aabb3f search_area(shootline_on_map.start - 5 * BS, shootline_on_map.end + 5 * BS);
|
||||||
|
search_area.repair();
|
||||||
|
|
||||||
// Use "logic in callback" pattern to avoid useless vector filling
|
// Use "logic in callback" pattern to avoid useless vector filling
|
||||||
std::vector<ServerActiveObject*> tmp;
|
std::vector<ServerActiveObject*> tmp;
|
||||||
getObjectsInsideRadius(tmp, shootline_on_map.getMiddle(),
|
getObjectsInArea(tmp, search_area, process);
|
||||||
0.5 * shootline_on_map.getLength() + 5 * BS, process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user