From: <re...@us...> - 2007-07-08 02:59:18
|
Revision: 27212 http://svn.sourceforge.net/crystal/?rev=27212&view=rev Author: res2002 Date: 2007-07-07 19:59:13 -0700 (Sat, 07 Jul 2007) Log Message: ----------- res fixed lighter2 problems introduced by r27190. Modified Paths: -------------- CS/trunk/apps/tools/lighter2/lightmap.h CS/trunk/apps/tools/lighter2/lightmapuv_simple.cpp CS/trunk/apps/tools/lighter2/lightmapuv_simple.h CS/trunk/docs/history.txt Modified: CS/trunk/apps/tools/lighter2/lightmap.h =================================================================== --- CS/trunk/apps/tools/lighter2/lightmap.h 2007-07-07 20:34:42 UTC (rev 27211) +++ CS/trunk/apps/tools/lighter2/lightmap.h 2007-07-08 02:59:13 UTC (rev 27212) @@ -160,6 +160,11 @@ width (lm.GetWidth ()), height (lm.GetHeight ()) { } + LightmapMask::~LightmapMask () + { + Lock(); + SwappableHeap::Free (maskData); + } float* GetMaskData() const { return maskData; } inline uint GetWidth () const { return width; } Modified: CS/trunk/apps/tools/lighter2/lightmapuv_simple.cpp =================================================================== --- CS/trunk/apps/tools/lighter2/lightmapuv_simple.cpp 2007-07-07 20:34:42 UTC (rev 27211) +++ CS/trunk/apps/tools/lighter2/lightmapuv_simple.cpp 2007-07-08 02:59:13 UTC (rev 27212) @@ -150,9 +150,9 @@ newFactory->uvsizes.GetExtend (lmID); groupUVsizes.Push (sizes[s].uvsize); - csArray<csVector2>& groupMinUVs = + /*csArray<csVector2>& groupMinUVs = newFactory->minuvs.GetExtend (lmID); - groupMinUVs.Push (minuvs[sizes[s].index]); + groupMinUVs.Push (minuvs[sizes[s].index]);*/ } #ifdef DUMP_SUBRECTANGLES @@ -529,7 +529,9 @@ size_t groupNum, Sector* sector, const csBitArray& pdBits) { // Prims will be layouted later... - size_t layoutID = this->layoutID++; + size_t layoutID = minuvs.GetSize(); + // Update minimum UVs for this particular layout + ComputeMinUVs (prims, groupNum, minuvs.GetExtend (layoutID)); parent->QueuePDPrimitives (this, prims, layoutID, groupNum, sector, pdBits, this->uvsizes[groupNum]); @@ -576,11 +578,46 @@ } } + void SimpleUVObjectLayouter::ComputeMinUVs (PrimitiveArray& prims, + size_t groupNum, + csArray<csVector2>& minuvs) + { + const csArray<csArray<size_t> >& coplanarGroup = coplanarGroups[groupNum]; + + for (size_t c = 0; c < coplanarGroup.GetSize(); c++) + { + const csArray<size_t>& coPrim = coplanarGroup[c]; + csVector2 minuv, maxuv; + + // Compute uv-size + Primitive& prim0 = prims[coPrim[0]]; + prim0.ComputeMinMaxUV (lightmapUVs, minuv, maxuv); + for (size_t p = 1; p < coPrim.GetSize(); p++) + { + Primitive& prim = prims[coPrim[p]]; + csVector2 pminuv, pmaxuv; + prim.ComputeMinMaxUV (lightmapUVs, pminuv, pmaxuv); + minuv.x = csMin (minuv.x, pminuv.x); + minuv.y = csMin (minuv.y, pminuv.y); + maxuv.x = csMax (maxuv.x, pmaxuv.x); + maxuv.y = csMax (maxuv.y, pmaxuv.y); + } + + /* Subtle: causes lumels to be aligned on a world space grid. + * The intention is that the lightmap coordinates for vertices + * for two adjacent faces are lined up nicely. + * @@@ Does not take object translation into account. */ + minuv.x = floor (minuv.x); + minuv.y = floor (minuv.y); + minuvs.Push (minuv); + } + } + void SimpleUVObjectLayouter::LayoutQueuedPrims (PrimitiveArray &prims, size_t layoutID, size_t groupNum, size_t lightmap, const csArray<csVector2>& positions, int dx, int dy) { - const csArray<csVector2>& minuvs = this->minuvs[groupNum]; + const csArray<csVector2>& minuvs = this->minuvs[/*groupNum*/layoutID]; PDLayoutedGroup layouted; layouted.lmID = uint (lightmap); layouted.remaps = positions; Modified: CS/trunk/apps/tools/lighter2/lightmapuv_simple.h =================================================================== --- CS/trunk/apps/tools/lighter2/lightmapuv_simple.h 2007-07-07 20:34:42 UTC (rev 27211) +++ CS/trunk/apps/tools/lighter2/lightmapuv_simple.h 2007-07-08 02:59:13 UTC (rev 27212) @@ -283,8 +283,7 @@ class SimpleUVObjectLayouter : public LightmapUVObjectLayouter { public: - SimpleUVObjectLayouter (SimpleUVFactoryLayouter* parent) : parent (parent), - layoutID (0) + SimpleUVObjectLayouter (SimpleUVFactoryLayouter* parent) : parent (parent) {} virtual size_t LayoutUVOnPrimitives (PrimitiveArray &prims, @@ -308,10 +307,16 @@ csArray<csVector2> remaps; }; csHash<PDLayoutedGroup, size_t> pdLayouts; + csArray<csArray<csVector2> > uvsizes; + /** + * Minimum UVs for each *layout* (since a group can appear multiple times + * on lightmaps) + */ csArray<csArray<csVector2> > minuvs; - csArray<csArray<csVector2> > uvsizes; - size_t layoutID; + void ComputeMinUVs (PrimitiveArray& prims, size_t groupNum, + csArray<csVector2>& minuvs); + void LayoutQueuedPrims (PrimitiveArray &prims, size_t groupNum, size_t layoutID, size_t lightmap, const csArray<csVector2>& positions, int dx, int dy); Modified: CS/trunk/docs/history.txt =================================================================== --- CS/trunk/docs/history.txt 2007-07-07 20:34:42 UTC (rev 27211) +++ CS/trunk/docs/history.txt 2007-07-08 02:59:13 UTC (rev 27212) @@ -8,6 +8,7 @@ 7-Jul-2007 - Marten fixed the OSX assistant to properly expose its intefaces. + - res fixed lighter2 problems introduced by r27190. 6-Jul-2007 - res fixed CS::SubRectangles::Split() neglecting to set the parent of newly created rectangles which would corrupt the internal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |