use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class Dbvt method update.
public boolean update(Node leaf, DbvtAabbMm volume, float margin) {
if (leaf.volume.Contain(volume)) {
return false;
}
Stack stack = Stack.enter();
Vector3f tmp = stack.allocVector3f();
tmp.set(margin, margin, margin);
volume.Expand(tmp);
update(leaf, volume);
stack.leave();
return true;
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class Dbvt method topdown.
private static Node topdown(Dbvt pdbvt, ObjectArrayList<Node> leaves, int bu_treshold) {
if (leaves.size() > 1) {
if (leaves.size() > bu_treshold) {
Stack stack = Stack.enter();
DbvtAabbMm vol = bounds(leaves);
Vector3f org = vol.Center(stack.allocVector3f());
ObjectArrayList[] sets = new ObjectArrayList[2];
for (int i = 0; i < sets.length; i++) {
sets[i] = new ObjectArrayList();
}
int bestaxis = -1;
int bestmidp = leaves.size();
int[][] splitcount = new int[][] { { 0, 0 }, { 0, 0 }, { 0, 0 } };
Vector3f x = stack.allocVector3f();
for (int i = 0; i < leaves.size(); i++) {
leaves.getQuick(i).volume.Center(x);
x.sub(org);
for (int j = 0; j < 3; j++) {
splitcount[j][x.dot(axis[j]) > 0f ? 1 : 0]++;
}
}
for (int i = 0; i < 3; i++) {
if ((splitcount[i][0] > 0) && (splitcount[i][1] > 0)) {
int midp = Math.abs(splitcount[i][0] - splitcount[i][1]);
if (midp < bestmidp) {
bestaxis = i;
bestmidp = midp;
}
}
}
if (bestaxis >= 0) {
//sets[0].reserve(splitcount[bestaxis][0]);
//sets[1].reserve(splitcount[bestaxis][1]);
split(leaves, sets[0], sets[1], org, axis[bestaxis]);
} else {
//sets[1].reserve(leaves.size()/2);
for (int i = 0, ni = leaves.size(); i < ni; i++) {
sets[i & 1].add(leaves.getQuick(i));
}
}
Node node = createnode(pdbvt, null, vol, null);
node.childs[0] = topdown(pdbvt, sets[0], bu_treshold);
node.childs[1] = topdown(pdbvt, sets[1], bu_treshold);
node.childs[0].parent = node;
node.childs[1].parent = node;
stack.leave();
return node;
} else {
bottomup(pdbvt, leaves);
return leaves.getQuick(0);
}
}
return leaves.getQuick(0);
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class Dbvt method update.
public boolean update(Node leaf, DbvtAabbMm volume, Vector3f velocity, float margin) {
if (leaf.volume.Contain(volume)) {
return false;
}
Stack stack = Stack.enter();
Vector3f tmp = stack.allocVector3f();
tmp.set(margin, margin, margin);
volume.Expand(tmp);
volume.SignedExpand(velocity);
update(leaf, volume);
stack.leave();
return true;
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class DbvtAabbMm method ProjectMinimum.
public float ProjectMinimum(Vector3f v, int signs) {
Vector3f[] b = new Vector3f[] { mx, mi };
Stack stack = Stack.enter();
Vector3f p = stack.allocVector3f();
p.set(b[(signs >> 0) & 1].x, b[(signs >> 1) & 1].y, b[(signs >> 2) & 1].z);
float result = p.dot(v);
stack.leave();
return result;
}
use of com.bulletphysics.util.Stack in project bdx by GoranM.
the class DbvtAabbMm method FromCR.
public static DbvtAabbMm FromCR(Vector3f c, float r, DbvtAabbMm out) {
Stack stack = Stack.enter();
Vector3f tmp = stack.allocVector3f();
tmp.set(r, r, r);
DbvtAabbMm result = FromCE(c, tmp, out);
stack.leave();
return result;
}
Aggregations