ObjectPtr LightSource::Copy() { LightSource *New = new LightSource(); /* Copy light source. */ *New = *this; if(!children.empty()) New->children[0] = Copy_Object(children[0]); New->Projected_Through_Object = Copy_Object(Projected_Through_Object); return (New); }
static OBJECT *Copy_Bound_Clip (OBJECT *Old) { OBJECT *Current, *New, *Prev, *First; First = Prev = NULL; for (Current = Old; Current != NULL; Current = Current->Sibling) { New = Copy_Object (Current); if (First == NULL) { First = New; } if (Prev != NULL) { Prev->Sibling = New; } Prev = New; } return (First); }
void cMouseCursor :: Copy( cSprite *nCopyObject, double x, double y ) { cSprite *new_Sprite = Copy_Object( nCopyObject, x, y ); if( !new_Sprite ) { printf( "MouseCursor CopyObject invald source Object\n" ); return; } if( new_Sprite->array == ARRAY_MASSIVE ) { AddMassiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_PASSIVE ) { AddPassiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_ACTIVE ) { AddActiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_ENEMY ) { AddEnemyObject( new_Sprite ); } else { printf( "MouseCursor CopyObject unknown Array : %d\n", new_Sprite->array ); delete new_Sprite; new_Sprite = NULL; } }
vector<ObjectPtr> Copy_Objects (vector<ObjectPtr>& Src) { vector<ObjectPtr> Dst; for(vector<ObjectPtr>::iterator it = Src.begin(); it != Src.end(); it++) Dst.push_back(Copy_Object(*it)); return (Dst); }
Camera& Camera::operator=(const Camera& src) { Assign_Vector(Location, src.Location); Assign_Vector(Direction, src.Direction); Assign_Vector(Up, src.Up); Assign_Vector(Right, src.Right); Assign_Vector(Sky, src.Sky); Assign_Vector(Look_At, src.Look_At); Assign_Vector(Focal_Point, src.Focal_Point); Focal_Distance = src.Focal_Distance; Aperture = src.Aperture; Blur_Samples = src.Blur_Samples; Blur_Samples_Min = src.Blur_Samples_Min; Confidence = src.Confidence; Variance = src.Variance; Type = src.Type; Angle = src.Angle; H_Angle = src.H_Angle; V_Angle = src.V_Angle; if (Tnormal != NULL) Destroy_Tnormal(Tnormal); Tnormal = src.Tnormal ? Copy_Tnormal(src.Tnormal) : NULL; if (Trans != NULL) Destroy_Transform(Trans); Trans = src.Trans ? Copy_Transform(src.Trans) : NULL; if (Bokeh != NULL) Destroy_Pigment(Bokeh); Bokeh = src.Bokeh ? Copy_Pigment(src.Bokeh) : NULL; for (std::vector<ObjectPtr>::iterator it = Meshes.begin(); it != Meshes.end(); it++) Destroy_Object(*it); Meshes.clear(); for (std::vector<ObjectPtr>::const_iterator it = src.Meshes.begin(); it != src.Meshes.end(); it++) Meshes.push_back(Copy_Object(*it)); Face_Distribution_Method = src.Face_Distribution_Method; Rays_Per_Pixel = src.Rays_Per_Pixel; Max_Ray_Distance = src.Max_Ray_Distance; Mesh_Index = src.Mesh_Index; for (int i = 0; i < 10; i++) { U_Xref[i] = src.U_Xref[i]; V_Xref[i] = src.V_Xref[i]; } Smooth = src.Smooth; return *this; }
TraceThreadData::TraceThreadData(shared_ptr<SceneData> sd): sceneData(sd), qualityFlags(9) { for(int i = 0; i < 4; i++) Fractal_IStack[i] = NULL; Fractal::Allocate_Iteration_Stack(Fractal_IStack, sceneData->Fractal_Iteration_Stack_Length); Max_Blob_Queue_Size = 1; Blob_Coefficient_Count = sceneData->Max_Blob_Components * 5; Blob_Interval_Count = sceneData->Max_Blob_Components * 2; Blob_Queue = reinterpret_cast<void **>(POV_MALLOC(sizeof(void **), "Blob Queue")); Blob_Coefficients = reinterpret_cast<DBL *>(POV_MALLOC(sizeof(DBL) * Blob_Coefficient_Count, "Blob Coefficients")); Blob_Intervals = new Blob_Interval_Struct [Blob_Interval_Count]; isosurfaceData = reinterpret_cast<ISO_ThreadData *>(POV_MALLOC(sizeof(ISO_ThreadData), "Isosurface Data")); isosurfaceData->ctx = NULL; isosurfaceData->current = NULL; isosurfaceData->cache = false; isosurfaceData->Inv3 = 1; isosurfaceData->fmax = 0.0; isosurfaceData->tl = 0.0; isosurfaceData->Vlength = 0.0; functionContext = new FPUContext(sceneData->functionVM, this); functionPatternContext.resize(sceneData->functionPatternCount); BCyl_Intervals.reserve(4*sceneData->Max_Bounding_Cylinders); BCyl_RInt.reserve(2*sceneData->Max_Bounding_Cylinders); BCyl_HInt.reserve(2*sceneData->Max_Bounding_Cylinders); Facets_Last_Seed = 0x80000000; timeType = kUnknownTime; cpuTime = 0; realTime = 0; for(vector<LightSource *>::iterator it = sceneData->lightSources.begin(); it != sceneData->lightSources.end(); it++) lightSources.push_back(static_cast<LightSource *> (Copy_Object(*it))); // all of these are for photons LightSource *photonLight = NULL; ObjectPtr photonObject = NULL; litObjectIgnoresPhotons = false; hitObject = false; // did we hit the target object? (for autostop) photonSpread = 0.0; // photon spread (in radians) photonDepth = 0.0; // total distance from light to intersection passThruThis = false; // is this a pass-through object? passThruPrev = false; // was the previous object pass-through? Light_Is_Global = false; // is the current light global? (not part of a light_group?) CrCache_MaxAge = 1; progress_index = 0; surfacePhotonMap = new PhotonMap(); mediaPhotonMap = new PhotonMap(); // advise the crackle cache's unordered_map that we don't mind hash collisions // while this is a very high load factor, the simple fact is that the cost of // allocating memory at render time (each insert into the table requires an alloc // as the container doesn't pre-emptively allocate, unlike e.g. std::vector) is // quite high, particularly when we have multiple threads contending for the heap // lock. mCrackleCache.max_load_factor(50.0); numberOfWaves = sd->numberOfWaves; Initialize_Waves(waveFrequencies, waveSources, numberOfWaves); }
void cMouseCursor :: Leveleditor_Update( void ) { if( !Leveleditor_CollsionCheck( posx, posy ) ) { string type; type.reserve( 60 ); if( iCollisionType == 1 ) // Massive { if( !MousePressed_left || !MouseObject ) { MouseObject = MassiveObjects[iCollisionNumber]; } if( MouseObject->halfmassive ) { type = "Halfmassive"; } else { type = "Massive"; } } else if( iCollisionType == 2 ) // Active { if( !MousePressed_left || !MouseObject ) { MouseObject = ActiveObjects[iCollisionNumber]; } if( MouseObject->type == TYPE_ENEMYSTOPPER ) { type = "Enemystopper"; } else if( MouseObject->type == TYPE_GOLDPIECE ) { type = "Goldpiece"; } else if( MouseObject->type == TYPE_MOON ) { type = "Moon (3-UP)"; } else if( MouseObject->type == TYPE_CLOUD ) { type = "Moving Cloud"; } else if( MouseObject->type == TYPE_HALFMASSIVE ) { if( !MouseObject->climbable ) { type = "Halfmassive"; } else { type = "Climbable"; } } else if( MouseObject->type == TYPE_GOLDBOX ) { type = "Gold box"; } else if( MouseObject->type == TYPE_BONUSBOX_MUSHROOM_FIRE ) { type = "Bonus box Mushroom - Fire"; } else if( MouseObject->type == TYPE_BONUSBOX_LIVE ) { type = "Bonus box Level-UP"; } else if( MouseObject->type == TYPE_SPINBOX ) { type = "Spin box"; } else if( MouseObject->type == TYPE_LEVELEXIT ) { cLevelExit *active = (cLevelExit*)MouseObject; if( active->levelchange == LVLCHANGE_WARP ) { type = "Levelexit (Warp)"; } else { type = "Levelexit (Beam)"; } } else { type = "Active"; } } else if( iCollisionType == 3 ) // Enemy { if( !MousePressed_left || !MouseObject ) { MouseObject = EnemyObjects[iCollisionNumber]; } if( MouseObject->type == TYPE_TURTLE ) { type = "Red Rurtle"; } else if( MouseObject->type == TYPE_GOOMBA ) { cGoomba *enemy = (cGoomba*)MouseObject; if( enemy->color == 1 ) // Red { type = "Blue Goomba"; } else { type = "Brown Goomba"; } } else if( MouseObject->type == TYPE_JPIRANHA ) { type = "Jumping Piranha"; } else if( MouseObject->type == TYPE_BANZAI_BILL ) { type = "Banzai Bill"; } else if( MouseObject->type == TYPE_REX ) { type = "Rex"; } else { type = "Enemy"; } } else if( iCollisionType == 4 ) // Player { if( !MousePressed_left || !MouseObject ) { MouseObject = (cSprite*)pPlayer; } type = "Maryo"; } else if( iCollisionType == 5 ) // Passive { if( !MousePressed_left || !MouseObject ) { MouseObject = PassiveObjects[iCollisionNumber]; } type = "Passive"; } else if( iCollisionType == 6 ) // Leveleditor Item Object { Menu_Item_Object *item = pLeveleditor->Get_Item_Object( iCollisionNumber + 1 ); if( item && !MousePressed_left ) { type = item->name; } else { type = ""; } if( !MouseObject ) { if( MousePressed_left ) { cSprite *new_Sprite = Copy_Object( item->Sprite_type, posx, posy ); if( !new_Sprite ) { printf( "Sprite copying Error\n" ); return; } if( new_Sprite->array == ARRAY_MASSIVE ) { AddMassiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_PASSIVE ) { AddPassiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_ACTIVE ) { AddActiveObject( new_Sprite ); } else if( new_Sprite->array == ARRAY_ENEMY ) { AddEnemyObject( new_Sprite ); } new_Sprite->posx = posx; new_Sprite->posy = posy; mouse_H = new_Sprite->rect.h/2; mouse_W = new_Sprite->rect.w/2; MouseObject = new_Sprite; } } else if( !MousePressed_left ) { MouseObject = NULL; } } else if( iCollisionType == 7 ) // Leveleditor Main Menu Object { Menu_Main_Object *item = pLeveleditor->Get_Main_Object( iCollisionNumber + 1 ); if( item && !MousePressed_left ) { type = item->name; } else { type = ""; } if( !MouseObject ) { if( MousePressed_left ) { if( item->Item_Menu_Id != MENU_FUNCTION ) { pLeveleditor->Load_Item_Menu( item->Item_Menu_Id ); pLeveleditor->Set_Main_Active( iCollisionNumber ); } else { item->pfunction(); MousePressed_left = 0; } } } else { MouseObject = NULL; } } else if( iCollisionType == 8 ) // Leveleditor Item Object Scroller { type = "Object Scroller"; if( !MouseObject && MousePressed_left ) { if( col_dir == DIR_LEFT ) { pLeveleditor->Item_scroller_left->active = 1; } else if( col_dir == DIR_RIGHT ) { pLeveleditor->Item_scroller_right->active = 1; } } else if( !MousePressed_left ) { MouseObject = NULL; } } else if( iCollisionType == 10 ) // A Dialog Box { if( iCollisionNumber >= 0 && ( pDialogManager->Get_Size() >= (unsigned int)iCollisionNumber ) ) { type = pDialogManager->Objects[iCollisionNumber]->identifier; if( MousePressed_left ) { pDialogManager->Objects[iCollisionNumber]->Get_Focus(); MousePressed_left = 0; } } } if( iCollisionType > 0 && iCollisionType < 6 && MouseObject ) { if( !MousePressed_left ) { if( iCollisionType == 4 || iCollisionType == 3 ) // If Player or Enemy ! { mouse_W = (int)( posx - MouseObject->startposx ); mouse_H = (int)( posy - MouseObject->startposy ); } else { mouse_W = (int)( posx - MouseObject->posx ); mouse_H = (int)( posy - MouseObject->posy ); } } SDL_Rect rect_pos; SDL_Surface *Position_info = NULL; char info[50]; rect_pos.x = mouseX + 20; rect_pos.y = mouseY + 35; sprintf( info ,"X : %d Y : %d", (int)MouseObject->posx, (int)MouseObject->posy ); Position_info = TTF_RenderText_Blended( font_16, info, colorBlack ); SDL_BlitSurface( Position_info, NULL, screen, &rect_pos ); SDL_FreeSurface( Position_info ); Position_info = TTF_RenderText_Blended( font_16, info, colorWhite ); rect_pos.x -= 2; rect_pos.y -= 2; SDL_BlitSurface( Position_info, NULL, screen, &rect_pos ); SDL_FreeSurface( Position_info ); } if( debugdisplay->counter <= 0 ) { sprintf( debugdisplay->text, "%s", type.c_str() ); debugdisplay->counter = 1; } } else { if( !MousePressed_left ) { MouseObject = NULL; if( !iCollisionType ) { mouse_W = 0; mouse_H = 0; } } } }