About Store Forum Documentation Contact



Post Reply 
Object Hard Copy
Author Message
AndrewBGS Offline
Member

Post: #1
Object Hard Copy
Since we are not allowed to make use of a copy constructor, I had to implement a hard copy method for my Item object to duplicate it; While it works in the inventory, when I attempt to drop the item into the world nothing happens; I am assuming something (physics maybe?) does not get copied correctly.

Here is my hardCopy method, I use it on a newly created item to make it a duplicate of an existing one.

Code:
void hardCopy(Item *item)
   {
   T.actor.adamping  (item.actor.adamping());
   T.actor.collision (item.actor.collision());
   T.actor.damping   (item.actor.damping());
   T.actor.dominance (item.actor.dominance());
   T.actor.group     (item.actor.group());
   T.actor.mass(item.actor.mass());
   T.actor.material  (item.actor.material());
   T.actor.matrix    (item.actor.matrix());
   T.actor.obj       (item.actor.obj());
   T.actor.user      (item.actor.user());
  
   T.scale  = item.scale;
   T.phys   = item.phys;
   T.material=item.material;
   T.mesh   = item.mesh;
   T.matrix(item.matrix());
  
   // Custom parameters:
   T.desc   = item.desc;  
   T.icon   = item.icon;
   T.limit  = item.limit;  
   T.name   = item.name;
   T.stack  = item.stack;  
   T.type   = item.type;
   T.self   = item.self;
   T.weight = item.weight;
   }

usage: Item item= new Item; item.hardCopy(originalItem);

The resulted item fails when being dropped into mode (dropping in world is done like in the tutorials). Can someone tell me what I'm doing wrong?

Maybe I'm missing some more parameters I should copy, or maybe because some (like physics) are pointers they aren't duplicated properly?
(This post was last modified: 03-24-2014 02:53 PM by AndrewBGS.)
03-24-2014 02:53 PM
Find all posts by this user Quote this message in a reply
Post Reply