Not jME3 related, but I need pointer here. Something going out of scope?

I don’t think tiredness has anything to do with what’s going on, but I guess at this point anything is possible.

I’m almost done working on my Octree but for some freaking reason there’s something weird going on…

The problematic part follows in an instant. Let me explain what happens.

In the code pasted below, fillTree is used to fill leaves of the tree. Each leaf has three sets of coordinates. If the sun’s coordinates fit inside that leaf, it goes in there. If not, we iterate to the next leaf, until the whole 300,000 to 500,000 stars are done. But that’s not important.

What is important here is that I tried to debug the problem. Look at “at HERE” below. The FileWriter here does its thing and write over 4000 files. Each time we found a leaf to put the sun, it writes a file. I know it should do more, but that’s the really my problem. At any rate, it might be related, but I don’t think so.

The part that is in those files look like this:

The followings should be filled.
Leaf: GalaxyOctree.TreeNode@58f39b3a
Entered suns: 501

Top Right: (181.87805, 0.0, 171.81053)
Middle : (90.939026, -11.448937, 85.905266)
Bott Left: (0.0, -22.897875, 0.0)
Parent: GalaxyOctree.TreeNode@5975d6ab

At "HERE" #2, everything is EMPTY. Like, gone!

Here's what that part looks like:

The following should be entirely filled.
Leaf: GalaxyOctree.TreeNode@199836ed
Top Right: (0.0, 0.0, 0.0)
Middle : (0.0, 0.0, 0.0)
Bott Left: (0.0, 0.0, 0.0)
Parent: GalaxyOctree.TreeNode@5caf993e
Has: 0

The question is WHY!?

I could understand if I'd try to print outside of the method; that, somehow, things had gone out of scope, but childrenList is declared at the top of the class like so:

public class OctreeList extends TreeNode {

private List childrenList = new LinkedList();
private TreeNode baseNode = new TreeNode();
private int counter;
public int numLeafs;
public int idT = 0;

public OctreeList() {

public void fillTree(Global g, ArrayList nodeStars) throws GameExceptions, IOException {
int idz = 0;
for (Star s : nodeStars) {

TreeNode toDelete = null;

Vector3f xyz = s.getXYZ();

for (TreeNode t : this.childrenList) {
if (t.isLeaf) {
if (xyz.x <= t.topRightCorner.x &&
xyz.x >= t.botLeftCorner.x &&
xyz.y <= t.topRightCorner.y &&
xyz.y >= t.botLeftCorner.y &&
xyz.z <= t.topRightCorner.z &&
xyz.z >= t.botLeftCorner.z) {
insertSun(t, s);
BufferedWriter during = new BufferedWriter(new FileWriter("./test/" + "leafs_during"+idT+idz+".txt"));
during.write("The followings should be filled.n");
during.write("Leaf: "+t+"n");
during.write("Entered suns: "+t.starsCount+"nn");
during.write("Top Right: "+t.topRightCorner+"n");
during.write("Middle : "+t.middle+"n");
during.write("Bott Left: "+t.botLeftCorner+"n");
during.write("Parent: "+t.parent+"n");

// If FULL, split here
if (t.starsCount>t.g.getMaxStarsOnScreen()) {
System.out.println("Splitting "+t+"");
System.out.println("Has: "+t.starsCount+" stars");
// Split this leaf
t.isLeaf = false;
t.isRoot = true;
t.lastRoot = true;
t.parent.lastRoot = false;
toDelete = t;
this.numLeafs = this.childrenList.size();
// Use t to fill the children we just made
this.refill(t, t.nodeStars);
t.nodeStars = null;
t.starsCount = 0;
if (toDelete!=null){
toDelete = null;
// HERE #2
BufferedWriter after = new BufferedWriter(new FileWriter("./" + "leafs_after.txt"));

for (int i=0,j=this.childrenList.size();i<j;i++) {
after.write("The following should be entirely filled.n");
after.write("Leaf: "+this.childrenList.get(i)+"n");
after.write("Top Right: "+this.childrenList.get(i).topRightCorner+"n");
after.write("Middle : "+this.childrenList.get(i).middle+"n");
after.write("Bott Left: "+this.childrenList.get(i).botLeftCorner+"n");
after.write("Parent: "+this.childrenList.get(i).parent+"n");
after.write("Has: "+this.childrenList.get(i).starsCount+"nn");

I hope it's clear.

I've been trying to figure out why everything seemed to go to hell in the last several hours and I can't find why. I'm at the end of my rope here. :(

Just noticed that if the JAVA code tags contain the HTML comment “< -” (without a space obviously) whatever follows it WILL be removed as if it were an HTML comment… Just a head’s up.

Oh and this has been cross-posted on too. I actually posted there first since it’s not, I really hope so, not a jME3 problem, but rather either me or Java.