btVector3 Copy Constructor

duncan
Posts: 2
Joined: Wed Sep 29, 2010 11:55 am

btVector3 Copy Constructor

Post by duncan »

Is there any particular reason why btVector3 relies on the default shallow copy constructor and doesn't do a deep copy of the array storing the data?
warmi
Posts: 5
Joined: Tue Nov 18, 2008 8:06 pm

Re: btVector3 Copy Constructor

Post by warmi »

There is no point trying to outsmart your compiler in terms of making shallow copies and in this case there is no need for anything else since the vector class doesn't allocate any memory in the first place.
duncan
Posts: 2
Joined: Wed Sep 29, 2010 11:55 am

Re: btVector3 Copy Constructor

Post by duncan »

Thanks. I did some further reading on copy constructors and found out that the default copy constructor copies the elements of static arrays properly - I'd previously thought it didn't.
williamholdin
Posts: 1
Joined: Mon Dec 28, 2015 6:38 am

Re: btVector3 Copy Constructor

Post by williamholdin »

warmi wrote:There is no point trying to outsmart your compiler in terms of making shallow copies and in this case there is no need for anything else since the vector class doesn't allocate any memory in the first place.
An object copy is a process where a data object has its attributes copied to another object of the same data type. In .Net Shallow copy and deep copy are used for copying data between objects.....more.

William