/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ #include "Engine/StdH.h" #include #include #include #include #include #include #include /* * Fill a 3d object from a selection in a brush mip. */ void CBrushMip::ToObject3D( CObject3D &ob, CBrushSectorSelection &selbscToCopy) { ASSERT(GetFPUPrecision()==FPT_53BIT); // get number of sectors in the selection INDEX ctSectors = selbscToCopy.Count(); // create that much sectors in the object CObjectSector *poscSectors = ob.ob_aoscSectors.New(ctSectors); // for each sector in the selection mip FOREACHINDYNAMICCONTAINER(selbscToCopy, CBrushSector, itbsc) { // fill corresponding sector in object from it itbsc->ToObjectSector(*poscSectors++); } // optimize the object, to remove unused elements // CBrush3D::OptimizeObject3D(ob); } /* * Fill a 3d object from a selection in a brush mip. */ void CBrushMip::ToObject3D( CObject3D &ob, CBrushSectorSelectionForCSG &selbscToCopy) { CSetFPUPrecision sfp(FPT_53BIT); // get number of sectors in the selection INDEX ctSectors = selbscToCopy.Count(); // create that much sectors in the object CObjectSector *poscSectors = ob.ob_aoscSectors.New(ctSectors); // for each sector in the selection mip FOREACHINDYNAMICCONTAINER(selbscToCopy, CBrushSector, itbsc) { // fill corresponding sector in object from it itbsc->ToObjectSector(*poscSectors++); } // optimize the object, to remove unused elements // CBrush3D::OptimizeObject3D(ob); } /* * Fill an object sector from a sector in brush. */ void CBrushSector::ToObjectSector(CObjectSector &osc) { // copy sector color and ambient osc.osc_colColor = bsc_colColor; osc.osc_colAmbient = bsc_colAmbient; osc.osc_ulFlags[0] = bsc_ulFlags; osc.osc_ulFlags[1] = bsc_ulFlags2; osc.osc_ulFlags[2] = bsc_ulVisFlags; osc.osc_strName = bsc_strName; // lock the object elements osc.LockAll(); // lock the brush elements LockAll(); /* Copy vertices. */ // get the number of vertices in brush INDEX ctVertices = bsc_abvxVertices.Count(); // create that much vertices in object osc.osc_aovxVertices.New(ctVertices); // copy all vertices for(INDEX iVertex=0; iVertex=sizePolygonProperties+3*sizeTextureProperties); UBYTE *pubUserData = (UBYTE*)&opo.opo_ubUserData; memcpy(pubUserData, &bpo.bpo_bppProperties, sizePolygonProperties); memcpy(pubUserData+sizePolygonProperties+0*sizeTextureProperties, &bpo.bpo_abptTextures[0].bpt_auProperties, sizeTextureProperties); memcpy(pubUserData+sizePolygonProperties+1*sizeTextureProperties, &bpo.bpo_abptTextures[1].bpt_auProperties, sizeTextureProperties); memcpy(pubUserData+sizePolygonProperties+2*sizeTextureProperties, &bpo.bpo_abptTextures[2].bpt_auProperties, sizeTextureProperties); *(ULONG*)(pubUserData+sizePolygonProperties+3*sizeTextureProperties) = bpo.bpo_colShadow; opo.opo_PolygonEdges.Lock(); // get the number of edges in brush polygon INDEX ctPolygonEdges = bpo.bpo_abpePolygonEdges.Count(); // create that much edges in object polygon opo.opo_PolygonEdges.New(ctPolygonEdges); // for all edges in brush polygon INDEX iPolygonEdge=0; FOREACHINSTATICARRAY(bpo.bpo_abpePolygonEdges, CBrushPolygonEdge, itbpe) { // get corresponding polygon edge in object polygon CObjectPolygonEdge &ope = opo.opo_PolygonEdges[iPolygonEdge]; // set edge reference ope.ope_Edge = &osc.osc_aoedEdges[bsc_abedEdges.Index(itbpe->bpe_pbedEdge)]; // set backward flag ope.ope_Backward = itbpe->bpe_bReverse; iPolygonEdge++; } opo.opo_PolygonEdges.Unlock(); } // unlock the object elements osc.UnlockAll(); // unlock the brush elements UnlockAll(); }