Dynamic BaseObject-Array
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2004 at 04:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.2
Platform: Windows ;
Language(s) : C++ ;---------
Hello all!I want to do something similar to
BaseTag *p = new BaseTag[num];
in "normal" Cpp.
I think, the/a (?) solution is to use GeAlloc:
BaseTag *p = (BaseTag* )GeAlloc(sizeof(BaseTag) * num);
But how can I tell these BaseTag-Objects now that they are of tag-type Trestriction? Do I have to use BaseTag::Alloc()?
Thanks in advance!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2004 at 05:15, xxxxxxxx wrote:
It isn't possible to get a continuous block of BaseTags, since C4D has to do the allocation. The closest you can get is an array of pointers to BaseTags, which you then have to initialize one by one:
const LONG NUM = 2; BaseTag** tags = new BaseTag*[NUM]; for (LONG i = 0; i < NUM; ++i) { tags[i] = BaseTag::Alloc(Trestriction); }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2004 at 05:43, xxxxxxxx wrote:
isn't that method very slow (due to the for-loop)?
I'm just interessted - I don't have another possibilty anyway -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2004 at 06:04, xxxxxxxx wrote:
No. It is inconceivable that the extra indirection would be even remotely noticable, unless you're creating a billion tags or so. And the for loop would have to be done anyway; there's no magic way for the C++ array to create the tags without looping, even if it's done behind the screen.
Please also keep in mind the words of wisdom: "Premature optimization is the root of all evil in programming." -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/06/2004 at 06:09, xxxxxxxx wrote:
hehe, ok, thanks