Page 1 of 1

#PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Wed Jan 06, 2016 8:24 am
by Psychophanta
HI!

This is a request in order to make easier the programming and also in order to correct some inconsistence and mess that for sure Fred and other PB programmers and members are aware about:
We can do this:

Code: Select all

malla.i=CreateCube(0,1); <- The variable 'malla' contains the ID of the cube mesh: MeshID(0)
textura.i=CreateTexture(0,256,256); <- The variable 'textura' contains the ID of the texture: TextureID(0)
material.i=CreateMaterial(0,textura); <- The variable 'material' contains the ID of the material: MaterialID(0)
entidad.i=CreateEntity(0,malla,material,0,0,0); <- The variable 'entidad' contains the ID of the Entity: EntityID(0)
But if #PB_Any is used, all the scenary logic is changed, because the returned values of the functions has nothing to do with the 'ID' of commands like MeshID(), MaterialID(), EntityID(), TextureID(), NodeID(), etc.
So with:

Code: Select all

malla.i=CreateCube(#PB_Any,1); <- here the variable 'malla' DOES NOT contain the ID of the cube mesh: MeshID(0), but the number of the mesh, i.e. the parameter of the MeshID() function.
now the variable 'malla' DOES NOT contain the ID of the cube mesh: MeshID(0), but the number of the mesh, i.e. the parameter of the MeshID() function.
So, using #PB_Any changes all the logic scenary for the subsequent code.


In fact, this would touch an old PB philosophy about #PB_Any and IDs in general in some native libs, i know, but i think this matter is important, and it probably could be fixed easely if the returned values (when #PB_Any is used or not used) was always the real internal ID and never a PB number.

Ok, I must admit I really advocate to abolish PB numbers in the PB language, because it would facilitate all the programming, and the code would be more readable, etc.

Re: #PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Wed Jan 06, 2016 4:26 pm
by mhs
And where do you get the PB Id in case of #PB_Any, if the function returns always the OS internal ID ?

Re: #PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Wed Jan 06, 2016 7:16 pm
by freak
Psychophanta wrote:This is a request in order to make easier the programming and also in order to correct some inconsistence and mess that for sure Fred and other PB programmers and members are aware about:
We can do this:

Code: Select all

malla.i=CreateCube(0,1); <- The variable 'malla' contains the ID of the cube mesh: MeshID(0)
textura.i=CreateTexture(0,256,256); <- The variable 'textura' contains the ID of the texture: TextureID(0)
material.i=CreateMaterial(0,textura); <- The variable 'material' contains the ID of the material: MaterialID(0)
entidad.i=CreateEntity(0,malla,material,0,0,0); <- The variable 'entidad' contains the ID of the Entity: EntityID(0)
This is an undocumented/unsupported feature. The functions are only documented to return nonzero/zero to indicate success/failure. The meaning of the value is only defined if #PB_Any is used.

Re: #PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Fri Jan 08, 2016 10:12 am
by Psychophanta
freak wrote: This is an undocumented/unsupported feature. The functions are only documented to return nonzero/zero to indicate success/failure. The meaning of the value is only defined if #PB_Any is used.
That's right, it is undocumented, so that not supported. Sorry!
The fact is these functions return the ID, even this programming way is not supported.
However, might be interesting to take a deep look to this issue, because with this current PB filosophy, the programmer is forced to deal with two different scopes: the PB numbers, and the '...ID()', which in my opinion it is an inconvenience.

Re: #PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Fri Jan 08, 2016 11:36 am
by DK_PETER
@Psychophanta
Personally, I really hate using a number to define an 'object' - unless it's a very - VERY small example.
In my oppinion - the use of numbers instead of descriptive names is extremely counter-productive and limiting in the long run.

The problem with your example is that you're mixing the two scopes together.
Use either descriptive names and #PB_Any or stick to numbers only.

Re: #PB_Any and IDs: MeshID(), MaterialID(), EntityID() ...

Posted: Fri Jan 08, 2016 12:36 pm
by Psychophanta
The above tip mixes numbers and ID, just because PB forces to use numbers.
What i am inviting to think deep about to change the current PB philosophy in order to avoid numbers and use only the ID in PureBasic everywhere, in every native libs.

Then, the above example would be:

Code: Select all

malla.i=CreateCube(1); <- The variable 'malla' contains the ID of the cube mesh: MeshID(0)
textura.i=CreateTexture(256,256); <- The variable 'textura' contains the ID of the texture: TextureID(0)
material.i=CreateMaterial(textura); <- The variable 'material' contains the ID of the material: MaterialID(0)
entidad.i=CreateEntity(malla,material,0,0,0); <- The variable 'entidad' contains the ID of the Entity: EntityID(0)
Or

Code: Select all

entidad.i=CreateEntity(CreateCube(1),CreateMaterial(CreateTexture(256,256)),0,0,0)
Notice this tips are just to show the idea.