Jump to content

GetChild bug?


Thareh
 Share

Recommended Posts

Hi!

I'm doing a lil' loop to go through all the children for my loaded Mesh like this:

 

For local X:Int = 1 to CountChildren( Mesh )
   Local Child:TEntity = GetChild( Mesh, X )
   Print GetEntityKey( Child, "name" )
Next

 

And this throws an error like this: "List index out of range".

Am I doing something wrong or is this a bug?

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

For Local X:Int = 1 To CountChildren( scene )
   Local Child:TEntity = GetChild( scene, X )
   Print GetEntityKey( Child, "name" )
Next

 

 

Works for me in Bmax with a loaded scene.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

I'm using it on a mesh, and it seems to be very random.

Sometimes when I export my mesh I get this problem, sometimes not.

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

If it works with the same mesh all the time, and it never works with a mesh with never works, then it's probably not a bug in the engine, but in the way how you export or in the modelling program you use.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

I'm modifying the same mesh, and exporting it again etc.

I can load the mesh just fine, and it shows up just fine;

But as soon as I loop through the children it crashes with that error.

Shouldn't CountChildren() just not count the parts that isn't correct if my mesh is faulty?

I'm exporting it using the 3d studio max exporter in the downloads section.

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

There might be a difference when you export it after you first opened 3DS Max, and when you export it a 2nd time while 3DS Max is still open (some internal variables being set differently). You could try if it works always when you close 3DS Max, open 3DSMax, then export it, and close 3DS Max again.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Guest Red Ocktober

try limiting your loop to CountChildren( scene )-1

 

i just put the same code into a scene and looped to -1 less than the child count and it showed the exact same children with an key named "name" as if i wound it out to the full count...

 

this may solve your problem... maybe...

 

 

--Mike

Link to comment
Share on other sites

I've tried that, It works sometimes :)

I'm gonna try exporting with a freshly started 3d Studio Max.

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

I tried exporting it with a freshly started 3d studio max, still the same issue.

Even if it's my meshes fault, shouldn't CountChildren & GrabChild skip invalid parts of the mesh?

The mesh shows up fine on the modelviewer, with the names of all entities etc.

So how does the modelviewer loop through all the children? :)

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

Maybe ModelViewer skips illegal pointers, kinda like this:

For local X:Int = 1 to CountChildren( Mesh )
Local Child:TEntity = GetChild( Mesh, X )
If Child Then
	Print GetEntityKey( Child, "name" )
EndIf
Next

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Found the issue now, I'm freeing a child in this loop which makes the CountChildren count go down so that GetChild goes short :P

There isn't any easier way to move an entity to another world other than change world => copy it => remove the original => change world back; right?

Core2Duo, 3.33GHz, Radeon HD 5850 Black Edition, 4GB RAM, 4 TB HDD, Windows 7.

Core2Duo, 2.00GHz, Geforce 9500m, 4GB RAM, 320 GB HDD, Windows 7.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...