Updated godot, voxel module; fixed spawners; added C++ border and radial points calculation
This commit is contained in:
@@ -60,7 +60,6 @@ void Spawner::place_scene(const StringName &name, const Transform &place)
|
||||
struct spawn_object obj;
|
||||
obj.xform = place;
|
||||
obj.active = false;
|
||||
obj.relative = false;
|
||||
obj.instance = -1;
|
||||
PoolVector<struct spawn_object> pos = positions[name];
|
||||
pos.resize(pos.size() + 1);
|
||||
@@ -72,21 +71,6 @@ void Spawner::place_scene(const StringName &name, const Transform &place)
|
||||
}
|
||||
void Spawner::place_scene_relative(const StringName &name, Node *parent, const Transform &place)
|
||||
{
|
||||
lock.lock();
|
||||
if (scenes.has(name)) {
|
||||
struct spawn_object obj;
|
||||
obj.xform = place;
|
||||
obj.active = false;
|
||||
obj.relative = true;
|
||||
obj.instance = -1;
|
||||
obj.parent_instance = parent->get_instance_id();
|
||||
PoolVector<struct spawn_object> pos = positions[name];
|
||||
pos.resize(pos.size() + 1);
|
||||
pos.write()[pos.size() - 1] = obj;
|
||||
positions[name] = pos;
|
||||
force_update = true;
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
void Spawner::update_view(Node *node, float distance)
|
||||
{
|
||||
@@ -109,30 +93,17 @@ void Spawner::update_view(Node *node, float distance)
|
||||
int i;
|
||||
PoolVector<struct spawn_object> pos = positions[*key];
|
||||
for (i = 0; i < pos.size(); i++) {
|
||||
Spatial *pnode = NULL;
|
||||
if (pos[i].relative) {
|
||||
Object *p = ObjectDB::get_instance(pos[i].parent_instance);
|
||||
pnode = Object::cast_to<Spatial>(p);
|
||||
assert(pnode);
|
||||
}
|
||||
if (!pos[i].active) {
|
||||
Transform x = pos[i].xform;
|
||||
Vector3 npos = x.origin;
|
||||
if (pnode)
|
||||
npos = pnode->get_global_transform().xform(npos);
|
||||
float d = org.distance_squared_to(x.origin);
|
||||
if (d < distance * distance) {
|
||||
Node *pn = scenes[*key]->instance();
|
||||
if (pn) {
|
||||
Spatial *sp = Object::cast_to<Spatial>(pn);
|
||||
if (sp) {
|
||||
if (pnode) {
|
||||
pnode->add_child(sp);
|
||||
sp->set_transform(x);
|
||||
} else {
|
||||
view->add_child(sp);
|
||||
sp->set_global_transform(x);
|
||||
}
|
||||
view->add_child(sp);
|
||||
sp->set_global_transform(x);
|
||||
pos.write()[i].instance = sp->get_instance_id();
|
||||
pos.write()[i].active = true;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user