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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

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

Post 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.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

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

Post by mhs »

And where do you get the PB Id in case of #PB_Any, if the function returns always the OS internal ID ?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

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

Post 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.
quidquid Latine dictum sit altum videtur
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

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

Post 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.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
DK_PETER
Addict
Addict
Posts: 904
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

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

Post 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.
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

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

Post 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.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply