Pointer to pointer array of scene nodes
Re: Pointer to pointer array of scene nodes
Can't you make your life easy and use an irr::array or std::vector and just pass a reference to that?
edit: Also randomMesh's solution should also work with other pointers - even easier without casting. Just needs a second parameter for size which is generally better anyway - unless it's really not possible to pass in this situation.
edit: Also randomMesh's solution should also work with other pointers - even easier without casting. Just needs a second parameter for size which is generally better anyway - unless it's really not possible to pass in this situation.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
I´m just looking for an elegant and efficient method, the irr::array would add overhead just to overcome what seems to be an ISO compiler restriction.
I could cast the ILightSceneNode pointers to int pointers, and visaversa, that would would work, but...
Any idea why void * to array of void *´s isn´t allowed? I mean that seems such a simple and reasonable usage... right?
My code is working fine, it just would be good to know why these restrictions even exist!
I could cast the ILightSceneNode pointers to int pointers, and visaversa, that would would work, but...
Any idea why void * to array of void *´s isn´t allowed? I mean that seems such a simple and reasonable usage... right?
My code is working fine, it just would be good to know why these restrictions even exist!
Re: Pointer to pointer array of scene nodes
Seriously somethings wrong with the way you do it, it doesn't matter what type of pointer the array holds, it's a frickin pointer.robmar wrote: As the size of the array is related to the size of a memory pointer, which is the same for all things, can´t see why the compiler should not allow it for classes, or void ptrs, which is even stranger!
Post a minimal test case that fails so others can try compiling it and maybe fix it.
Guessing isn't fun anymore
![Wink :wink:](./images/smilies/icon_wink.gif)
Working on game: Marrbles (Currently stopped).
Re: Pointer to pointer array of scene nodes
Already did that, CuteAlien confirmed the error. See earlier.
Re: Pointer to pointer array of scene nodes
You did not provide any compilable sample that produces the error(s)robmar wrote:Already did that, CuteAlien confirmed the error. See earlier.
Working on game: Marrbles (Currently stopped).
Re: Pointer to pointer array of scene nodes
its in the posts: 2 lines of code.
Re: Pointer to pointer array of scene nodes
I did? You mean the 2 lines where you mixed up array to pointers with pointer to an array? Those certainly can't be assigned to each other as they are different things. If that would compile the compiler would be broken!
But unless you _know_ (aka - you did profile it!) that using an irr::array reference instead really is the bottleneck in your application you simply shouldn't care about that. Or use the solution from randomMesh which looks _better_ anyway than passing a const array. I mean it's just 1 more parameter - unless this is really your absolute bottleneck which you absolutely can't have it's just not worth even having harder to read code in your application to avoid that!
But unless you _know_ (aka - you did profile it!) that using an irr::array reference instead really is the bottleneck in your application you simply shouldn't care about that. Or use the solution from randomMesh which looks _better_ anyway than passing a const array. I mean it's just 1 more parameter - unless this is really your absolute bottleneck which you absolutely can't have it's just not worth even having harder to read code in your application to avoid that!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
well, working on the principle that in large programs it can me the hundreds or thousands of little inefficiencies that add up to create overall inefficiency.
Finally I used a different arrangement:-
irr::core::vector3df m_3dfLights[ MAX_LIGHTS ]; // Current location of active lights updated before each frame is drawn
vector3df (*m_pLights)[MAX_LIGHTS];
m_pGoochShader->m_pLights = &m_3dfLights;
Finally I used a different arrangement:-
irr::core::vector3df m_3dfLights[ MAX_LIGHTS ]; // Current location of active lights updated before each frame is drawn
vector3df (*m_pLights)[MAX_LIGHTS];
m_pGoochShader->m_pLights = &m_3dfLights;
Re: Pointer to pointer array of scene nodes
Usually doesn't work like that. If you do some profiling you will notice that usually you have at most a handful of lines which just dominate the profiling results. And once you get those bottlenecks removed your application speed will increase a lot while all the minor optimizations usually don't even show up. Although sometimes through profiling you might find out that what you thought would be minor thing isn't actually minor - and that is when you start working on such tricks.robmar wrote:well, working on the principle that in large programs it can me the hundreds or thousands of little inefficiencies that add up to create overall inefficiency.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
Sure, I agree with you, but if you have code in loops like this, getting executed 60 times a second, and there are another 100 or 1000 items with inefficiency, it adds up.
Apart from that, I don´t like inefficient code, even small pieces of it, so I try to code efficiently and as elegantly as possible, which usually needs more time than I have.
This post was just to see if anyone knew how to resolve the pointer to array of ILightSceneNode pointers.
Unless I missed something, nobody has found a solution?...
Apart from that, I don´t like inefficient code, even small pieces of it, so I try to code efficiently and as elegantly as possible, which usually needs more time than I have.
This post was just to see if anyone knew how to resolve the pointer to array of ILightSceneNode pointers.
Unless I missed something, nobody has found a solution?...
Re: Pointer to pointer array of scene nodes
Well... you got several solutions for the pointer to an array of ILightSceneNode pointers thing ... just not the pointer to array of constant size of ILightSceneNode pointers. Still don't know why you are not using randomMesh's solution which is better than using a constant array anyway. The second parameter?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: Pointer to pointer array of scene nodes
Donald Knuth wrote:We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"
"Whoops..."
Re: Pointer to pointer array of scene nodes
I used to write device drivers in ASM, so my experience was without ISO type restrictions, and passing a pointer to an array of pointers wouldn´t have raised its ugly head! ![Smile :)](./images/smilies/icon_smile.gif)
I´m just curious to know why passing a ptr of an array of pointers, type void* or ILightSceneNode, should be prohibited in ANSI/ISO C++.
I don´t "need" to know, but I´d like to know!
I already have solved my original coding issue by using a ptr to an array of vect3df´s, so now its just an academic question.
![Smile :)](./images/smilies/icon_smile.gif)
I´m just curious to know why passing a ptr of an array of pointers, type void* or ILightSceneNode, should be prohibited in ANSI/ISO C++.
I don´t "need" to know, but I´d like to know!
I already have solved my original coding issue by using a ptr to an array of vect3df´s, so now its just an academic question.
Re: Pointer to pointer array of scene nodes
But you have 2 solutions already here which compile for the " ptr of an array of pointers". Just none for "ptr of an array with const size of pointers".
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Pointer to pointer array of scene nodes
I´m just curious to know why passing a ptr of an array of pointers (with size constant), type void* or ILightSceneNode, should be prohibited in ANSI/ISO C++.