Now spawn relative nodes via Spawner too
This commit is contained in:
@@ -71,6 +71,16 @@ void Spawner::place_scene(const StringName &name, const Transform &place)
|
||||
}
|
||||
void Spawner::place_scene_relative(const StringName &name, Node *parent, const Transform &place)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
lock.lock();
|
||||
if (scenes.has(name)) {
|
||||
Node *n = scenes[name]->instance();
|
||||
Spatial *sp = Object::cast_to<Spatial>(n);
|
||||
sp->set_transform(place);
|
||||
parent->call_deferred("add_child", sp);
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
void Spawner::update_view(Node *node, float distance)
|
||||
{
|
||||
@@ -95,7 +105,6 @@ void Spawner::update_view(Node *node, float distance)
|
||||
for (i = 0; i < pos.size(); i++) {
|
||||
if (!pos[i].active) {
|
||||
Transform x = pos[i].xform;
|
||||
Vector3 npos = x.origin;
|
||||
float d = org.distance_squared_to(x.origin);
|
||||
if (d < distance * distance) {
|
||||
Node *pn = scenes[*key]->instance();
|
||||
|
||||
Reference in New Issue
Block a user