Added traffic
This commit is contained in:
@@ -104,34 +104,38 @@ void Spawner::update_view(Node *node, float distance)
|
||||
int i;
|
||||
PoolVector<struct spawn_object> pos = positions[*key];
|
||||
for (i = 0; i < pos.size(); i++) {
|
||||
if (!pos[i].active) {
|
||||
if (!pos[i].active && !pos[i].pooled) {
|
||||
Transform x = pos[i].xform;
|
||||
float d = org.distance_squared_to(x.origin);
|
||||
if (d < distance * distance && pos[i].instance < 0) {
|
||||
int j;
|
||||
Node *pn = NULL;
|
||||
bool pooling = false;
|
||||
for (j = 0; j < pos.size(); j++) {
|
||||
if (j == i)
|
||||
continue;
|
||||
if (!pos[j].active && pos[j].instance >= 0 && pos[j].pooled) {
|
||||
pos.write()[i].instance = pos[j].instance;
|
||||
pos.write()[j].instance = -1;
|
||||
pos.write()[j].pooled = false;
|
||||
Object *po = ObjectDB::get_instance(pos[i].instance);
|
||||
if (po) {
|
||||
pn = Object::cast_to<Node>(po);
|
||||
if (pn) {
|
||||
pooling = true;
|
||||
break;
|
||||
if (pos.size() > 4) {
|
||||
for (j = 0; j < pos.size(); j++) {
|
||||
if (j == i)
|
||||
continue;
|
||||
if (!pos[j].active && pos[j].instance >= 0 && pos[j].pooled) {
|
||||
pos.write()[i].instance = pos[j].instance;
|
||||
pos.write()[j].instance = -1;
|
||||
pos.write()[j].pooled = false;
|
||||
Object *po = ObjectDB::get_instance(pos[i].instance);
|
||||
if (po) {
|
||||
pn = Object::cast_to<Node>(po);
|
||||
if (pn) {
|
||||
pooling = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pn)
|
||||
pn = scenes[*key]->instance();
|
||||
assert(pn);
|
||||
if (pn) {
|
||||
Spatial *sp = Object::cast_to<Spatial>(pn);
|
||||
assert(sp);
|
||||
if (sp) {
|
||||
if (!pooling)
|
||||
view->add_child(sp);
|
||||
@@ -144,7 +148,7 @@ void Spawner::update_view(Node *node, float distance)
|
||||
memfree(pn);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (pos[i].active) {
|
||||
Transform x = pos[i].xform;
|
||||
float d = org.distance_squared_to(x.origin);
|
||||
if (d > distance * distance + 2500.0f) {
|
||||
|
||||
Reference in New Issue
Block a user