i would try it but what trollchar suggested already helped)
what i did was:
I added bool flag to object and then when i remove objects i just delete only objects and dont erase vector elements(so it still has all elements along with removed ones). And when i update my class of objects i just do the checking like if (object->getFlag()==true) object->update() . No need to set false flag since i remove objects anyway
@trollingchar i actually do iterate through all objects when updating them but i dont when i access them at runtime after some event triggered. I guess i was just looking for an issue in wrong place)
v[i] = nullptr; // ok o = nullptr; // sets local o to nullptr, vector is unaffected
i dont like the null pointer approach because boolean flag is named and explicit
if you forget why that null is here you're in trouble
user92578
8:54 AM
I don't like the idea of guarding everything that's relevant with a boolean, the ID handle approach suggested seems much nicer and is something I've used a lot
The indirection explicitly reminds you that you need to look up the element and it's might not be there anymore. Some languages even remind you that the looked-up element might not exist in the map on a type-system level (Like in Rust, the lookup is an Option<Value>)
@trollingchar there s no way to get index from object pointer ?
user92578
You could also wrap the ID into something that looks like std::optional, i.e. with a has_entity() and entity() methods for testing existence and fetching the value
You probably need to have some remove-set that you empty at end of every frame. (Ofc. you can make it a vector, no reason to have the overhead of a set)
user92578
That's almost a must anyways with any kind of storage ^
Hi! I have a problem with webgl. I'm using vanilla webgl and I'm trying to port a Three.js code.
I want to replicate this example https://mattdesl.github.io/webgl-wireframes/app/ that does a wireframe render with barycentric coordinates.
What I want is this image:
I have a render that if the z axis is screen facing has a wrong result (some faces are white filled) while if the z axis is in the opposite direction I have the desired result
Here is a picture in the middle that clearly show a white filled face that superimposes to the wireframe