ObjectPtr Copy_Object (ObjectPtr Old) { ObjectPtr New; if(Old == NULL) return NULL; New = Old->Copy(); /* * The following copying of OBJECT_FIELDS is redundant if Copy * did *New = *Old but we cannot assume it did. It is safe for * Copy to do *New = *Old but it should not otherwise * touch OBJECT_FIELDS. */ New->Type = Old->Type; New->Bound = Old->Bound; New->Clip = Old->Clip; New->BBox = Old->BBox; New->Flags = Old->Flags; New->Ph_Density = Old->Ph_Density; New->RadiosityImportance = Old->RadiosityImportance; // TODO FIXME - An explanation WHY this is important would be nice [CLi] New->LLights.clear(); // important New->Texture = Copy_Textures (Old->Texture); New->Interior_Texture = Copy_Textures (Old->Interior_Texture); if(Old->interior != NULL) New->interior = new Interior(*(Old->interior)); else New->interior = NULL; /* NK 1998 */ New->UV_Trans = Copy_Transform(Old->UV_Trans); /* NK ---- */ // TODO: we really ought to decide whether or not it's useful to maintain // the overhead of having multiple clip and bound objects ... it is // after all possible for the user to use CSG and give us one object // meaning we could use a plain pointer here. if (Old->Bound.empty() == false) New->Bound = Copy_Objects(Old->Bound); if (Old->Clip.empty() == false) { // note that in this case the objects are shared and should only be // destroyed the once !!! ... to be frank POV really needs a reference- // counted system for sharing objects with copy-on-write semantics. if(Old->Bound != Old->Clip) New->Clip = Copy_Objects(Old->Clip); else New->Clip = New->Bound; } return New; }
OBJECT *Copy_Object (OBJECT *Old) { OBJECT *New; if (Old == NULL) { return (NULL); } New = (OBJECT *)Copy(Old); /* * The following copying of OBJECT_FIELDS is redundant if Copy * did *New = *Old but we cannot assume it did. It is safe for * Copy to do *New = *Old but it should not otherwise * touch OBJECT_FIELDS. */ New->Methods = Old->Methods; New->Type = Old->Type; New->Sibling = Old->Sibling; New->Texture = Old->Texture; New->Bound = Old->Bound; New->Clip = Old->Clip; New->BBox = Old->BBox; New->Flags = Old->Flags; New->LLights = NULL; /* Important */ New->Sibling = NULL; /* Important */ New->Texture = Copy_Textures (Old->Texture); New->Interior_Texture = Copy_Textures (Old->Interior_Texture); New->Bound = Copy_Bound_Clip (Old->Bound); New->Interior = Copy_Interior(Old->Interior); /* NK 1998 */ New->UV_Trans = Copy_Transform(Old->UV_Trans); /* NK ---- */ if (Old->Bound != Old->Clip) { New->Clip = Copy_Bound_Clip (Old->Clip); } else { New->Clip = New->Bound; } return (New); }
MATERIAL *Copy_Material(MATERIAL *Old) { MATERIAL *New; if (Old != NULL) { New = Create_Material(); *New = *Old; New->Texture = Copy_Textures(Old->Texture); New->Interior_Texture = Copy_Textures(Old->Interior_Texture); New->Interior = Copy_Interior(Old->Interior); return(New); } else { return(NULL); } }
MATERIAL *Copy_Material(const MATERIAL *Old) { MATERIAL *New; if (Old != NULL) { New = Create_Material(); *New = *Old; New->Texture = Copy_Textures(Old->Texture); New->Interior_Texture = Copy_Textures(Old->Interior_Texture); if (Old->interior != NULL) New->interior = new Interior(*(Old->interior)); return(New); } else { return(NULL); } }
BLEND_MAP_ENTRY *Copy_BMap_Entries (BLEND_MAP_ENTRY *Old, int Map_Size, int Type) { int i; BLEND_MAP_ENTRY *New; if (Old != NULL) { New = Create_BMap_Entries (Map_Size); for (i = 0; i < Map_Size; i++) { switch (Type) { case PIGMENT_TYPE: New[i].Vals.Pigment = Copy_Pigment(Old[i].Vals.Pigment); break; case NORMAL_TYPE: New[i].Vals.Tnormal = Copy_Tnormal(Old[i].Vals.Tnormal); break; case TEXTURE_TYPE: New[i].Vals.Texture = Copy_Textures(Old[i].Vals.Texture); break; case COLOUR_TYPE: case SLOPE_TYPE: New[i] = Old[i]; break; } } } else { New = NULL; } return (New); }