THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/02/2003 at 08:23, xxxxxxxx wrote:
Creating objects in that way is not very efficient ;-) your main object (plugin object) can be cloned for many reasons, including just rendering, what I was meaning was that you will end up using resources that you don't need, that takes vital memory away from other areas that may or may not need it. It isn't dangerous as in it'll explode the computer, but in that you should not get into bad habits, and that is one!_<_o:_<_o:p_>_o:p>
When creating a generator object, it is similar to creating a shader, it needs to be as efficient and fast as possible, resize is not that fast, it will have to duplicate the memory allocation then refill it, it is useful, but in situations where you need speed and efficiency, it isn't that good to rely on it, and just creating one monster object is also not wis_<_o:_<_o:p_>_
If you really can't work out how many points/polys your object is going to need, then you need to look at how your system works, or build the object up from smaller ones where you do know the sizes, but not too many (like one object per blade of grass!) otherwise you again run into efficiency issues. If you really have no way to know the overall size, then maybe it is a difficult choice of memory and speed, guess it depends how much waste is le_<_o:_<_o:p_>_.
... an_<_o:_<_o:p_>_ur answers :o)
1> why j_<_o:_<_o:p_>_m? you don't have to!
2> NO NEVER! you should never repeat using resize over and over, it will be very very slow! resize itself is not a killer (Windows support memory resizing, don't know about Mac, but any memory resize is not that efficient, n_<_o:_<_o:p_>_llocation for that matter!).
3> is like a memorypool, if the waste is minor it is no problem, but if you really have no way to know how big your object will be, then the size is a guess? and if not a complete guess, you must know the final size? or I guess you do know approximately the final size, so allocate on the big side? hope that is_<_o:_<_o:p_>_o) or do you have shares in RAM ;-)
Yes it is "safe", you won't crash, you can do anything you like to your polygon _<_o:_<_o:p_>_provided it is returned as a valid object.
There are many ways to create objects, the overall best way is to know just how big it will need to be! in the case of the project Samir is working on, last time I saw anything it was creating single objects in a hierarchy, that is fine, just like the Atom _<_o:_<_o:p_>_, no join, no resize, no waste, nice and fast ;-)
If it works, use it, but watch out that it doesn't bite back later :o) two things should be (tried) to keep in mind when programming anything, especially in something as CPU hungry as a 3d app, speed, efficiency, and can you do it faster! always the last one, time test every part, know how long it takes, why it takes that long, and can it be faster and more efficient. Takes time, but the end product is worth it! maybe I'm just a bit old school, I still remember spending hours just tweaking a few lines of 68000 assembler back in the good old days just to get that extra bit of speed :o)