Do we need to delete the objects?

Do you mean:

PTADouble[16*4] <==> PTADouble[64]

We write 16*4 is only indicate that it represent a 2 dimension array of double[16][4]?

By the way, I can not find the head files of:

PTA_LMatrix4f
PTA_LVecBase4f
PTA_LVecBase3f

16*4 = 64. So of course they are the same thing.

Those classes are in pta_LMatrix4.h and PTA_LVecBase3.h, etc, files, in the mathutil directory.

Is is new, created on 27 FEB 10 :stuck_out_tongue:

When PT() variable is reassigned, does it decrease the reference?

Please see the code below:

pvector<CMetaInterval*> sequences;

PT(CLerpNodePathInterval) int1, int2;
int1 = new CLerpNodePathInterval(...); //C1
int2 = new CLerpNodePathInterval(...); //C2

PT(CMetaInterval) seq = new CMetaInterval("int1, int2"); //S1
seq->add_c_interval(int1);
seq->add_c_interval(int2);
seq->loop();
sequences.push_back(seq);
....
//then we use int1, int2 and seq again, what about their reference?

int1 = new CLerpNodePathInterval(...);  //C3
int2 = new CLerpNodePathInterval(...);  //C4
seq = new CMetaInterval("int1, int2");  //S2
seq->add_c_interval(int1);
seq->add_c_interval(int2);
seq->loop();
sequences.push_back(seq);
...

//do C1, C2, S1 exist now?

Yes, reassigning a PT() to a new value correctly decreases the reference on the previous value.

Note that you can answer these questions yourself, by testing the reference count with something like int1->get_ref_count().

David

I can create new NodePath instance and add it to pvector in a function call, how to create new CMetaInterval instance dynamically in a function and keep it in a pvector<…>?

Can you give us a code skeleton?

What do you mean? It’s not hard, something like:

pvector< PT(CMetaInterval) > my_vector;
my_vector.push_back(new CMetaInterval(...));

David

I find one interesting thing, when I give CMetaInterval instances the same name, only the last one works. If I give them different names, all of them work! Why?

This is a “feature” of intervals: [interval rotation problems)

David

Is it not the feature of vector? I find the answer when try to track each Interval by their names. :slight_smile:

My apologies, I don’t understand what you’re saying here.

David

I mean vector may optimize the items according to their names, i.e., when meet the objects with the same name, pack them as one!

It is only a joke!

I think you schedule the intervals by their names.