From 6d6737a02212a772a6216d6db9927638553bf45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Wed, 7 Sep 2011 14:25:32 +0200 Subject: [PATCH] Add two new Material Shapes Octagon and Smoother, more chunk antialias Previously, smooth materials would get extra triangles at the top to create slopes instead of steps. Now those also appear at the bottom. Smooth also gets generally smoother at the bottom, while Rough gets rougher at the top. The new Smoother material is somewhere between Flat and Smooth. Octagon is like Flat but also gets straight slope triangles. --- docs/de.po | 24 ++- docs/sdk/material/ocm.xml | 2 +- .../FrozenFortress.ocs/Material.ocg/Ice.ocm | 2 +- .../FrozenFortress.ocs/Material.ocg/Snow.ocm | 2 +- .../Hideout.ocs/Material.ocg/Ametyst.ocm | 2 +- .../Hideout.ocs/Material.ocg/Ruby.ocm | 2 +- planet/Material.ocg/Brick.ocm | 2 +- planet/Material.ocg/BrickSoft.ocm | 2 +- planet/Material.ocg/Coal.ocm | 2 +- planet/Material.ocg/Earth.ocm | 2 +- planet/Material.ocg/Gold.ocm | 2 +- planet/Material.ocg/Granite.ocm | 2 +- planet/Material.ocg/Ice.ocm | 2 +- planet/Material.ocg/ORE.ocm | 2 +- planet/Material.ocg/Rock.ocm | 2 +- planet/Material.ocg/Sand.ocm | 2 +- planet/Material.ocg/SandDry.ocm | 2 +- planet/Material.ocg/Snow.ocm | 2 +- planet/Material.ocg/Sulphur.ocm | 2 +- planet/Material.ocg/Tunnel.ocm | 2 +- src/game/landscape/C4Landscape.cpp | 182 +++++++++++------- src/game/landscape/C4Landscape.h | 4 +- src/game/landscape/C4Material.cpp | 113 ++++++----- src/game/landscape/C4Material.h | 27 +-- 24 files changed, 226 insertions(+), 162 deletions(-) diff --git a/docs/de.po b/docs/de.po index c14472cc0..6c7240111 100644 --- a/docs/de.po +++ b/docs/de.po @@ -3,16 +3,16 @@ # PeterW # Sven2 # Armin Burgmeier , 2010. -# Günther Brammer , 2009, 2010, 2011. # Benedict Etzel , 2011. +# Günther Brammer , 2009, 2010, 2011. # msgid "" msgstr "" "Project-Id-Version: OpenClonk documentation\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-09-05 22:05+0200\n" -"PO-Revision-Date: 2011-07-01 15:00+0100\n" -"Last-Translator: Benedict Etzel \n" +"POT-Creation-Date: 2011-09-06 23:32+0200\n" +"PO-Revision-Date: 2011-09-06 23:16+0200\n" +"Last-Translator: Günther Brammer \n" "Language-Team: German <>\n" "Language: German\n" "MIME-Version: 1.0\n" @@ -153,7 +153,6 @@ msgstr "Scripte" #: sdk/particle/index.xml:161(h) #: sdk/definition/properties.xml:6(title) #: sdk/definition/properties.xml:7(h) -#: sdk/definition/properties.xml:22(caption) msgid "Properties" msgstr "Eigenschaften" @@ -13822,8 +13821,8 @@ msgid "Shape" msgstr "Shape" #: sdk/material/ocm.xml:31(col) -msgid "Shape of surface: 0 smooth, 1 smooth on top, 2 semi rough, 3 rough." -msgstr "Landschaftsform: 0 glatt, 1 oben glatt, 2 halbrauh, 3 komplett rauh." +msgid "Shape of surface: Flat (0), Octagon, FlatTop (1), Smoother, Smooth (2) or Rough (3)." +msgstr "Form der Oberfläche: Flat (0, flach), Octagon (achteckig), FlatTop (1, oben flach), Smoother (weicher), Smooth (2, weich) oder Rough (3, rau)." #: sdk/material/ocm.xml:34(col) msgid "Density" @@ -15367,6 +15366,10 @@ msgstr "Die Engine ruft zu Zeiten die folgenden Funktionen in Objektscripten auf msgid "Every object has a number of properties that are handled by the engine. Typically, these are inherited from the object's Prototype, an Object Definition. A Property of an Object Definition is defined with the local keyword in the Definition's script:" msgstr "Jedes Objekt besitzt Properties die von der engine interpretiert werden. Normalerweise werden diese vom Prototyp des objekts abgeleitet, seiner Objektdefinition. Eine Property einer Objektdefinition wird mit dem local-Schlüsselwort im Definitionsscript definiert." +#: sdk/definition/properties.xml:22(caption) +msgid "Object Properties" +msgstr "Objekteigenschaften" + #: sdk/definition/properties.xml:30(col) #: sdk/definition/properties.xml:50(col) #: sdk/definition/properties.xml:90(col) @@ -15398,11 +15401,11 @@ msgstr "[int, int]" #: sdk/definition/properties.xml:121(col) msgid "The Objects's major Z-Position. See ." -msgstr "" +msgstr "Die hauptsächliche Z-Position des Objekts. Siehe auch ." #: sdk/definition/properties.xml:126(col) msgid "The Object's minor Z-Position. Negative values are behind the landscape, positive values before it." -msgstr "" +msgstr "Die sekundäre Z-Position des Objekts. Negative Werte sind hinter der Landschaft, positive vor ihr." #: sdk/definition/procedures.xml:8(text) msgid "For object activity the engine offers various standard procedures which perform typical physcial behaviour. In procedure WALK, for instance, the activity automatically changes to \"Jump\" if the ground under the feet is lost." @@ -16989,6 +16992,9 @@ msgstr "c4group.exe (Windows) c4group (Linux) c4group (Mac)" msgid "This command line program is used for processing group files. A list of command line options is available by starting the program without parameters via command line (not by double clicking)." msgstr "Dieses Kommandozeilen-Programm dient zum Bearbeiten von Gruppendateien. Es kann nicht per Doppelklick, sondern nur per Kommandozeile (Eingabeaufforderung) gestartet werden. Auskunft über alle verfügbaren Kommandozeilenparameter erhält man, indem man das Programm ohne weitere Parameter über die Kommandozeile startet." +#~ msgid "Shape of surface: 0 smooth, 1 smooth on top, 2 semi rough, 3 rough." +#~ msgstr "Landschaftsform: 0 glatt, 1 oben glatt, 2 halbrauh, 3 komplett rauh." + #~ msgid "The object will only be visible for it's owner and the spectators." #~ msgstr "Das Objekt wird nur für seinen Besitzer und Zuschauer sichtbar." diff --git a/docs/sdk/material/ocm.xml b/docs/sdk/material/ocm.xml index aebc68032..7616bab1b 100644 --- a/docs/sdk/material/ocm.xml +++ b/docs/sdk/material/ocm.xml @@ -28,7 +28,7 @@ Shape Integer - Shape of surface: 0 smooth, 1 smooth on top, 2 semi rough, 3 rough. + Shape of surface: Flat (0), Octagon, FlatTop (1), Smoother, Smooth (2) or Rough (3). Density diff --git a/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Ice.ocm b/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Ice.ocm index 7c5b8961b..132261619 100644 --- a/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Ice.ocm +++ b/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Ice.ocm @@ -1,6 +1,6 @@ [Material] Name=Ice -Shape=1 +Shape=TopFlat Density=50 Friction=15 BlastFree=1 diff --git a/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Snow.ocm b/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Snow.ocm index 87fa7a79b..ebb0ae639 100644 --- a/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Snow.ocm +++ b/planet/BackToTheRocks.ocf/FrozenFortress.ocs/Material.ocg/Snow.ocm @@ -1,6 +1,6 @@ [Material] Name=Snow -Shape=2 +Shape=Smooth Density=50 Friction=40 DigFree=1 diff --git a/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ametyst.ocm b/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ametyst.ocm index 4ed7bcc0c..6bfdc53f0 100644 --- a/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ametyst.ocm +++ b/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ametyst.ocm @@ -1,6 +1,6 @@ [Material] Name=Ametyst -Shape=3 +Shape=Rough Density=50 Friction=15 BlastFree=1 diff --git a/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ruby.ocm b/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ruby.ocm index 72abfd1d1..777a001f4 100644 --- a/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ruby.ocm +++ b/planet/BackToTheRocks.ocf/Hideout.ocs/Material.ocg/Ruby.ocm @@ -1,6 +1,6 @@ [Material] Name=Ruby -Shape=3 +Shape=Rough Density=50 Friction=15 BlastFree=1 diff --git a/planet/Material.ocg/Brick.ocm b/planet/Material.ocg/Brick.ocm index 21b8b4ae0..3853cb926 100644 --- a/planet/Material.ocg/Brick.ocm +++ b/planet/Material.ocg/Brick.ocm @@ -1,6 +1,6 @@ [Material] Name=Brick -Shape=0 +Shape=Flat Density=50 Friction=15 Placement=80 diff --git a/planet/Material.ocg/BrickSoft.ocm b/planet/Material.ocg/BrickSoft.ocm index 40e86e620..61a6f00d9 100644 --- a/planet/Material.ocg/BrickSoft.ocm +++ b/planet/Material.ocg/BrickSoft.ocm @@ -1,6 +1,6 @@ [Material] Name=BrickSoft -Shape=0 +Shape=Flat Density=50 Placement=60 TextureOverlay=brick1 diff --git a/planet/Material.ocg/Coal.ocm b/planet/Material.ocg/Coal.ocm index 843e386d7..00c712c1d 100644 --- a/planet/Material.ocg/Coal.ocm +++ b/planet/Material.ocg/Coal.ocm @@ -1,6 +1,6 @@ [Material] Name=Coal -Shape=3 +Shape=Rough Density=50 Friction=75 DigFree=1 diff --git a/planet/Material.ocg/Earth.ocm b/planet/Material.ocg/Earth.ocm index 78ce342fa..c403c7679 100644 --- a/planet/Material.ocg/Earth.ocm +++ b/planet/Material.ocg/Earth.ocm @@ -1,6 +1,6 @@ [Material] Name=Earth -Shape=2 +Shape=Smooth Density=50 Friction=80 DigFree=1 diff --git a/planet/Material.ocg/Gold.ocm b/planet/Material.ocg/Gold.ocm index 9f75549c4..9becb8a14 100644 --- a/planet/Material.ocg/Gold.ocm +++ b/planet/Material.ocg/Gold.ocm @@ -1,6 +1,6 @@ [Material] Name=Gold -Shape=3 +Shape=Rough Density=50 Friction=100 BlastFree=1 diff --git a/planet/Material.ocg/Granite.ocm b/planet/Material.ocg/Granite.ocm index a16e8c98e..8dd61e70e 100644 --- a/planet/Material.ocg/Granite.ocm +++ b/planet/Material.ocg/Granite.ocm @@ -1,6 +1,6 @@ [Material] Name=Granite -Shape=3 +Shape=Rough Density=50 Friction=100 MaxAirSpeed=100 diff --git a/planet/Material.ocg/Ice.ocm b/planet/Material.ocg/Ice.ocm index bbe641df9..7ad77b78a 100644 --- a/planet/Material.ocg/Ice.ocm +++ b/planet/Material.ocg/Ice.ocm @@ -1,6 +1,6 @@ [Material] Name=Ice -Shape=1 +Shape=TopFlat Density=50 Friction=15 DigFree=1 diff --git a/planet/Material.ocg/ORE.ocm b/planet/Material.ocg/ORE.ocm index 160a64057..06dbb0731 100644 --- a/planet/Material.ocg/ORE.ocm +++ b/planet/Material.ocg/ORE.ocm @@ -1,6 +1,6 @@ [Material] Name=Ore -Shape=3 +Shape=Rough Density=50 Friction=100 BlastFree=1 diff --git a/planet/Material.ocg/Rock.ocm b/planet/Material.ocg/Rock.ocm index 73ccebe3e..b909e8e98 100644 --- a/planet/Material.ocg/Rock.ocm +++ b/planet/Material.ocg/Rock.ocm @@ -1,6 +1,6 @@ [Material] Name=Rock -Shape=3 +Shape=Rough Density=50 Friction=100 BlastFree=1 diff --git a/planet/Material.ocg/Sand.ocm b/planet/Material.ocg/Sand.ocm index d4f1e57b7..6e9fb7e51 100644 --- a/planet/Material.ocg/Sand.ocm +++ b/planet/Material.ocg/Sand.ocm @@ -1,6 +1,6 @@ [Material] Name=Sand -Shape=2 +Shape=Smooth Density=50 Friction=80 DigFree=1 diff --git a/planet/Material.ocg/SandDry.ocm b/planet/Material.ocg/SandDry.ocm index 84c7eb99b..5f8931e21 100644 --- a/planet/Material.ocg/SandDry.ocm +++ b/planet/Material.ocg/SandDry.ocm @@ -1,6 +1,6 @@ [Material] Name=SandDry -Shape=2 +Shape=Smooth Density=50 Friction=30 DigFree=1 diff --git a/planet/Material.ocg/Snow.ocm b/planet/Material.ocg/Snow.ocm index 5819710a9..033da8a5f 100644 --- a/planet/Material.ocg/Snow.ocm +++ b/planet/Material.ocg/Snow.ocm @@ -1,6 +1,6 @@ [Material] Name=Snow -Shape=2 +Shape=Smooth Density=50 Friction=40 DigFree=1 diff --git a/planet/Material.ocg/Sulphur.ocm b/planet/Material.ocg/Sulphur.ocm index 9cdc910fe..98331e9ef 100644 --- a/planet/Material.ocg/Sulphur.ocm +++ b/planet/Material.ocg/Sulphur.ocm @@ -1,6 +1,6 @@ [Material] Name=Sulphur -Shape=3 +Shape=Rough Density=50 Friction=75 DigFree=1 diff --git a/planet/Material.ocg/Tunnel.ocm b/planet/Material.ocg/Tunnel.ocm index 05c886e84..7a311717a 100644 --- a/planet/Material.ocg/Tunnel.ocm +++ b/planet/Material.ocg/Tunnel.ocm @@ -1,5 +1,5 @@ [Material] Name=Tunnel -Shape=2 +Shape=Smooth Placement=5 TextureOverlay=tunnel diff --git a/src/game/landscape/C4Landscape.cpp b/src/game/landscape/C4Landscape.cpp index c9796a5d6..6094c2565 100644 --- a/src/game/landscape/C4Landscape.cpp +++ b/src/game/landscape/C4Landscape.cpp @@ -1586,56 +1586,64 @@ uint32_t C4Landscape::ChunkyRandom(uint32_t & iOffset, uint32_t iRange) return (iOffset ^ MapSeed) % iRange; } -void C4Landscape::DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int32_t iChunkType, uint32_t cro) +void C4Landscape::DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, C4MaterialCoreShape Shape, uint32_t cro) { - BYTE top_rough = 0; BYTE side_rough = 0; + unsigned int top_rough = 0, side_rough = 0, bottom_rough = 0; // what to do? - switch (iChunkType) + switch (Shape) { - case C4M_Flat: + case C4M_Flat: case C4M_Octagon: Surface8->Box(tx, ty, tx + wdt, ty + hgt, mcol); return; case C4M_TopFlat: - top_rough = 0; side_rough = 1; + top_rough = 0; side_rough = 2; bottom_rough = 4; break; case C4M_Smooth: - top_rough = 1; side_rough = 1; + top_rough = 2; side_rough = 2; bottom_rough = 2; break; case C4M_Rough: - top_rough = 1; side_rough = 2; + top_rough = 4; side_rough = 4; bottom_rough = 4; + break; + case C4M_Smoother: + top_rough = 1; side_rough = 1; bottom_rough = 1; break; - case C4M_None: // no drawing - return; } int vtcs[16]; - uint32_t rx = Max(wdt / 2, 1); + unsigned int rx = Max(wdt / 2, 1); - vtcs[0] = tx - ChunkyRandom(cro, rx / 2); vtcs[1] = ty - ChunkyRandom(cro, rx / 2 * top_rough); - vtcs[2] = tx - ChunkyRandom(cro, rx * side_rough); vtcs[3] = ty + hgt / 2; - vtcs[4] = tx - ChunkyRandom(cro, rx); vtcs[5] = ty + hgt + ChunkyRandom(cro, rx); - vtcs[6] = tx + wdt / 2; vtcs[7] = ty + hgt + ChunkyRandom(cro, 2 * rx); - vtcs[8] = tx + wdt + ChunkyRandom(cro, rx); vtcs[9] = ty + hgt + ChunkyRandom(cro, rx); - vtcs[10] = tx + wdt + ChunkyRandom(cro, rx * side_rough); vtcs[11] = ty + hgt / 2; - vtcs[12] = tx + wdt + ChunkyRandom(cro, rx / 2); vtcs[13] = ty - ChunkyRandom(cro, rx / 2 * top_rough); - vtcs[14] = tx + wdt / 2; vtcs[15] = ty - ChunkyRandom(cro, rx * top_rough); + vtcs[0] = tx - ChunkyRandom(cro, rx * side_rough / 4); vtcs[1] = ty - ChunkyRandom(cro, rx * top_rough / 4); + vtcs[2] = tx - ChunkyRandom(cro, rx * side_rough / 2); vtcs[3] = ty + hgt / 2; + vtcs[4] = tx - ChunkyRandom(cro, rx * side_rough / 4); vtcs[5] = ty + hgt + ChunkyRandom(cro, rx * bottom_rough / 4); + vtcs[6] = tx + wdt / 2; vtcs[7] = ty + hgt + ChunkyRandom(cro, rx * bottom_rough / 2); + vtcs[8] = tx + wdt + ChunkyRandom(cro, rx * side_rough / 4); vtcs[9] = ty + hgt + ChunkyRandom(cro, rx * bottom_rough / 4); + vtcs[10] = tx + wdt + ChunkyRandom(cro, rx * side_rough / 2); vtcs[11] = ty + hgt / 2; + vtcs[12] = tx + wdt + ChunkyRandom(cro, rx * side_rough / 4); vtcs[13] = ty - ChunkyRandom(cro, rx * top_rough / 4); + vtcs[14] = tx + wdt / 2; vtcs[15] = ty - ChunkyRandom(cro, rx * top_rough / 2); ForPolygon(vtcs, 8, NULL, NULL, mcol); } -void C4Landscape::DrawSmoothOChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, BYTE flip, uint32_t cro) +void C4Landscape::DrawSmoothOChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int flip, uint32_t cro) { int vtcs[8]; - uint32_t rx = Max(wdt / 2, 1); + unsigned int rx = Max(wdt / 2, 1); - vtcs[0] = tx; vtcs[1] = ty - ChunkyRandom(cro, rx / 2); + vtcs[0] = tx; vtcs[1] = ty; vtcs[2] = tx; vtcs[3] = ty + hgt; vtcs[4] = tx + wdt; vtcs[5] = ty + hgt; - vtcs[6] = tx + wdt; vtcs[7] = ty - ChunkyRandom(cro, rx / 2); + vtcs[6] = tx + wdt; vtcs[7] = ty; - if (flip) - { vtcs[0] = tx + wdt / 2; vtcs[1] = ty + hgt / 3; } - else - { vtcs[6] = tx + wdt / 2; vtcs[7] = ty + hgt / 3; } + switch (flip) + { + case 0: vtcs[0] = tx + wdt / 2; vtcs[1] += hgt / 3; vtcs[7] -= ChunkyRandom(cro, rx / 2); break; + case 1: vtcs[2] = tx + wdt / 2; vtcs[3] -= hgt / 3; vtcs[5] += ChunkyRandom(cro, rx / 2); break; + case 2: vtcs[4] = tx + wdt / 2; vtcs[5] -= hgt / 3; vtcs[3] += ChunkyRandom(cro, rx / 2); break; + case 3: vtcs[6] = tx + wdt / 2; vtcs[7] += hgt / 3; vtcs[1] -= ChunkyRandom(cro, rx / 2); break; + case 4: vtcs[0] = tx + wdt / 2; vtcs[1] += hgt / 2; break; + case 5: vtcs[2] = tx + wdt / 2; vtcs[3] -= hgt / 2; break; + case 6: vtcs[4] = tx + wdt / 2; vtcs[5] -= hgt / 2; break; + case 7: vtcs[6] = tx + wdt / 2; vtcs[7] += hgt / 2; break; + } ForPolygon(vtcs, 4, NULL, NULL, mcol); } @@ -1700,67 +1708,93 @@ void C4Landscape::DrawCustomShape(CSurface8 * sfcMap, C4MaterialShape *shape, in void C4Landscape::ChunkOZoom(CSurface8 * sfcMap, int32_t iMapX, int32_t iMapY, int32_t iMapWdt, int32_t iMapHgt, int32_t iTexture, int32_t iOffX, int32_t iOffY) { - int32_t iX,iY,iChunkWidth,iChunkHeight,iToX,iToY; - int32_t iIFT; - BYTE byMapPixel, byMapPixelBelow; - int iMapWidth,iMapHeight; C4Material *pMaterial = ::TextureMap.GetEntry(iTexture)->GetMaterial(); if (!pMaterial) return; - int32_t iChunkType=pMaterial->MapChunkType; - BYTE byColor=MatTex2PixCol(iTexture); + C4MaterialCoreShape iChunkType = pMaterial->MapChunkType; + BYTE byColor = MatTex2PixCol(iTexture); // Get map & landscape size - sfcMap->GetSurfaceSize(iMapWidth,iMapHeight); + int iMapWidth, iMapHeight; + sfcMap->GetSurfaceSize(iMapWidth, iMapHeight); // Clip desired map segment to map size - iMapX=BoundBy(iMapX,0,iMapWidth-1); iMapY=BoundBy(iMapY,0,iMapHeight-1); - iMapWdt=BoundBy(iMapWdt,0,iMapWidth-iMapX); iMapHgt=BoundBy(iMapHgt,0,iMapHeight-iMapY); + iMapX = BoundBy(iMapX, 0, iMapWidth - 1); + iMapY = BoundBy(iMapY, 0, iMapHeight - 1); + iMapWdt = BoundBy(iMapWdt, 0, iMapWidth - iMapX); + iMapHgt = BoundBy(iMapHgt, 0, iMapHeight - iMapY); // get chunk size - iChunkWidth=MapZoom; iChunkHeight=MapZoom; + int iChunkWidth = MapZoom, iChunkHeight = MapZoom; // Scan map lines - if (pMaterial->MapChunkType != C4M_None) + for (int iY = iMapY; iY < iMapY + iMapHgt; iY++) { - for (iY=iMapY; iY_GetPix(iX, iY); + // Landscape target coordinate horizontal + int iToX = iX * iChunkWidth + iOffX; + // Here's a chunk of the texture-material to zoom + if ((MapPixel & 127) == iTexture) + { + // Determine IFT + iIFT = 0; if (MapPixel >= 128) iIFT = IFT; + // Draw chunk + DrawChunk(iToX, iToY, iChunkWidth, iChunkHeight, byColor + iIFT, iChunkType, (iX<<16)+iY); + } + // Other chunk, check for slope smoothers + else if (iChunkType == C4M_Smooth || iChunkType == C4M_Smoother || iChunkType == C4M_Octagon) { - // Map scan line start - byMapPixel=sfcMap->_GetPix(iX, iY); // Map scan line pixel below - byMapPixelBelow = sfcMap->GetPix(iX, iY + 1); - // Landscape target coordinate horizontal - iToX=iX*iChunkWidth+iOffX; - // Here's a chunk of the texture-material to zoom - if ((byMapPixel & 127) == iTexture) + uint8_t below = sfcMap->GetPix(iX, iY + 1) & 127; + uint8_t above = sfcMap->GetPix(iX, iY - 1) & 127; + uint8_t left = sfcMap->GetPix(iX - 1, iY) & 127; + uint8_t right = sfcMap->GetPix(iX + 1, iY) & 127; + // do not fill a tiny hole + if (below == iTexture && above == iTexture && left == iTexture && right == iTexture) + continue; + int flat = iChunkType == C4M_Octagon ? 4 : 0; + // Smooth chunk & same texture-material below + if (iY < iMapHeight - 1 && below == iTexture) { - // Determine IFT - iIFT=0; if (byMapPixel>=128) iIFT=IFT; - // Draw chunk - DrawChunk(iToX,iToY,iChunkWidth,iChunkHeight,byColor+iIFT,pMaterial->MapChunkType,(iX<<16)+iY); - } - // Other chunk, check for slope smoothers - else - // Smooth chunk & same texture-material below - if ((iChunkType==C4M_Smooth) && (iY 0 && left == iTexture) { - // Same texture-material on left - if ((iX>0) && ((sfcMap->GetPix(iX-1, iY) & 127)==iTexture)) - { - // Determine IFT - iIFT=0; if (sfcMap->GetPix(iX-1, iY) >= 128) iIFT=IFT; - // Draw smoother - DrawSmoothOChunk(iToX,iToY,iChunkWidth,iChunkHeight,byColor+iIFT,0,(iX<<16)+iY); - } - // Same texture-material on right - if ((iXGetPix(iX+1, iY) & 127)==iTexture)) - { - // Determine IFT - iIFT=0; if (sfcMap->GetPix(iX+1, iY) >= 128) iIFT=IFT; - // Draw smoother - DrawSmoothOChunk(iToX,iToY,iChunkWidth,iChunkHeight,byColor+iIFT,1,(iX<<16)+iY); - } + // Determine IFT + iIFT = 0; if (sfcMap->GetPix(iX-1, iY) >= 128) iIFT = IFT; + // Draw smoother + DrawSmoothOChunk(iToX, iToY, iChunkWidth, iChunkHeight, byColor + iIFT, 3 + flat, (iX<<16) + iY); } + // Same texture-material on right + if (iX < iMapWidth - 1 && right == iTexture) + { + // Determine IFT + iIFT = 0; if (sfcMap->GetPix(iX+1, iY) >= 128) iIFT = IFT; + // Draw smoother + DrawSmoothOChunk(iToX, iToY, iChunkWidth, iChunkHeight, byColor + iIFT, 0 + flat, (iX<<16)+iY); + } + } + // Smooth chunk & same texture-material above + if (iY > 0 && above == iTexture) + { + // Same texture-material on left + if (iX > 0 && left == iTexture) + { + // Determine IFT + iIFT = 0; if (sfcMap->GetPix(iX - 1, iY) >= 128) iIFT = IFT; + // Draw smoother + DrawSmoothOChunk(iToX, iToY, iChunkWidth, iChunkHeight, byColor + iIFT, 2 + flat, (iX<<16)+iY); + } + // Same texture-material on right + if (iX < iMapWidth - 1 && right == iTexture) + { + // Determine IFT + iIFT = 0; if (sfcMap->GetPix(iX + 1, iY) >= 128) iIFT = IFT; + // Draw smoother + DrawSmoothOChunk(iToX, iToY, iChunkWidth, iChunkHeight, byColor + iIFT, 1 + flat, (iX<<16)+iY); + } + } } } } diff --git a/src/game/landscape/C4Landscape.h b/src/game/landscape/C4Landscape.h index 2cd5746e8..853628125 100644 --- a/src/game/landscape/C4Landscape.h +++ b/src/game/landscape/C4Landscape.h @@ -210,8 +210,8 @@ protected: void ExecuteScan(); int32_t DoScan(int32_t x, int32_t y, int32_t mat, int32_t dir); uint32_t ChunkyRandom(uint32_t &iOffset, uint32_t iRange); // return static random value, according to offset and MapSeed - void DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int32_t iChunkType, uint32_t cro); - void DrawSmoothOChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, BYTE flip, uint32_t cro); + void DrawChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, C4MaterialCoreShape Shape, uint32_t cro); + void DrawSmoothOChunk(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t mcol, int flip, uint32_t cro); void DrawCustomShapePoly(const C4MaterialShape::Poly &poly, int32_t off_x, int32_t off_y, int32_t mcol); void DrawCustomShape(CSurface8 * sfcMap, C4MaterialShape *shape, int32_t iMapX, int32_t iMapY, int32_t iMapWdt, int32_t iMapHgt, int32_t iTexture, int32_t mcol, int32_t iOffX, int32_t iOffY); void ChunkOZoom(CSurface8 * sfcMap, int32_t iMapX, int32_t iMapY, int32_t iMapWdt, int32_t iMapHgt, int32_t iTexture,int32_t iOffX=0,int32_t iOffY=0); diff --git a/src/game/landscape/C4Material.cpp b/src/game/landscape/C4Material.cpp index 79f8a897e..aa990356e 100644 --- a/src/game/landscape/C4Material.cpp +++ b/src/game/landscape/C4Material.cpp @@ -232,7 +232,7 @@ void C4MaterialCore::Clear() sBelowTempConvertTo.Clear(); sAboveTempConvertTo.Clear(); *Name='\0'; - MapChunkType = 0; + MapChunkType = C4M_Flat; ShapeTexture.Clear(); Density = 0; Friction = 0; @@ -303,54 +303,73 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp) { if (pComp->isCompiler()) Clear(); pComp->Name("Material"); - pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", "" )); - pComp->Value(mkNamingAdapt(ColorAnimation, "ColorAnimation", 0 )); - pComp->Value(mkNamingAdapt(MapChunkType, "Shape", 0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(ShapeTexture, StdCompiler::RCT_All),"ShapeTexture", "" )); - pComp->Value(mkNamingAdapt(Density, "Density", 0 )); - pComp->Value(mkNamingAdapt(Friction, "Friction", 0 )); - pComp->Value(mkNamingAdapt(DigFree, "DigFree", 0 )); - pComp->Value(mkNamingAdapt(BlastFree, "BlastFree", 0 )); - pComp->Value(mkNamingAdapt(Blast2Object,"Blast2Object", C4ID::None )); - pComp->Value(mkNamingAdapt(Dig2Object, "Dig2Object", C4ID::None )); - pComp->Value(mkNamingAdapt(Dig2ObjectRatio, "Dig2ObjectRatio", 0 )); - pComp->Value(mkNamingAdapt(Dig2ObjectCollect, "Dig2ObjectCollect", 0 )); - pComp->Value(mkNamingAdapt(Blast2ObjectRatio, "Blast2ObjectRatio", 0 )); - pComp->Value(mkNamingAdapt(Blast2PXSRatio, "Blast2PXSRatio", 0 )); - pComp->Value(mkNamingAdapt(Instable, "Instable", 0 )); - pComp->Value(mkNamingAdapt(MaxAirSpeed, "MaxAirSpeed", 0 )); - pComp->Value(mkNamingAdapt(MaxSlide, "MaxSlide", 0 )); - pComp->Value(mkNamingAdapt(WindDrift, "WindDrift", 0 )); - pComp->Value(mkNamingAdapt(Inflammable, "Inflammable", 0 )); - pComp->Value(mkNamingAdapt(Incindiary, "Incindiary", 0 )); - pComp->Value(mkNamingAdapt(Corrode, "Corrode", 0 )); - pComp->Value(mkNamingAdapt(Corrosive, "Corrosive", 0 )); - pComp->Value(mkNamingAdapt(Extinguisher, "Extinguisher", 0 )); - pComp->Value(mkNamingAdapt(Soil, "Soil", 0 )); - pComp->Value(mkNamingAdapt(Placement, "Placement", 0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(sTextureOverlay, StdCompiler::RCT_IdtfAllowEmpty),"TextureOverlay", "" )); - pComp->Value(mkNamingAdapt(OverlayType, "OverlayType", 0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(sPXSGfx, StdCompiler::RCT_IdtfAllowEmpty), "PXSGfx", "" )); - pComp->Value(mkNamingAdapt(PXSGfxRt, "PXSGfxRt", TargetRect0 )); - pComp->Value(mkNamingAdapt(PXSGfxSize, "PXSGfxSize", PXSGfxRt.Wdt )); - pComp->Value(mkNamingAdapt(TempConvStrength, "TempConvStrength", 0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(sBlastShiftTo, StdCompiler::RCT_IdtfAllowEmpty),"BlastShiftTo", "" )); - pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvert, StdCompiler::RCT_IdtfAllowEmpty),"InMatConvert", "" )); - pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"InMatConvertTo", "" )); - pComp->Value(mkNamingAdapt(InMatConvertDepth, "InMatConvertDepth", 0 )); - pComp->Value(mkNamingAdapt(AboveTempConvert, "AboveTempConvert", 0 )); - pComp->Value(mkNamingAdapt(AboveTempConvertDir, "AboveTempConvertDir",0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(sAboveTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"AboveTempConvertTo", "" )); - pComp->Value(mkNamingAdapt(BelowTempConvert, "BelowTempConvert", 0 )); - pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir",0 )); - pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty),"BelowTempConvertTo", "" )); - pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0 )); - pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10 )); + pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", "")); + pComp->Value(mkNamingAdapt(ColorAnimation, "ColorAnimation", 0)); + + const StdEnumEntry Shapes[] = + { + { "Flat", C4M_Flat }, + { "TopFlat", C4M_TopFlat }, + { "Smooth", C4M_Smooth }, + { "Rough", C4M_Rough }, + { "Octagon", C4M_Octagon }, + { "Smoother", C4M_Smoother }, + { NULL, C4M_Flat } + }; + pComp->Value(mkNamingAdapt(mkEnumAdaptT(MapChunkType, Shapes), + "Shape", C4M_Flat)); + pComp->Value(mkNamingAdapt(mkParAdapt(ShapeTexture, StdCompiler::RCT_All), + "ShapeTexture", "")); + pComp->Value(mkNamingAdapt(Density, "Density", 0)); + pComp->Value(mkNamingAdapt(Friction, "Friction", 0)); + pComp->Value(mkNamingAdapt(DigFree, "DigFree", 0)); + pComp->Value(mkNamingAdapt(BlastFree, "BlastFree", 0)); + pComp->Value(mkNamingAdapt(Blast2Object, "Blast2Object", C4ID::None)); + pComp->Value(mkNamingAdapt(Dig2Object, "Dig2Object", C4ID::None)); + pComp->Value(mkNamingAdapt(Dig2ObjectRatio, "Dig2ObjectRatio", 0)); + pComp->Value(mkNamingAdapt(Dig2ObjectCollect, "Dig2ObjectCollect", 0)); + pComp->Value(mkNamingAdapt(Blast2ObjectRatio, "Blast2ObjectRatio", 0)); + pComp->Value(mkNamingAdapt(Blast2PXSRatio, "Blast2PXSRatio", 0)); + pComp->Value(mkNamingAdapt(Instable, "Instable", 0)); + pComp->Value(mkNamingAdapt(MaxAirSpeed, "MaxAirSpeed", 0)); + pComp->Value(mkNamingAdapt(MaxSlide, "MaxSlide", 0)); + pComp->Value(mkNamingAdapt(WindDrift, "WindDrift", 0)); + pComp->Value(mkNamingAdapt(Inflammable, "Inflammable", 0)); + pComp->Value(mkNamingAdapt(Incindiary, "Incindiary", 0)); + pComp->Value(mkNamingAdapt(Corrode, "Corrode", 0)); + pComp->Value(mkNamingAdapt(Corrosive, "Corrosive", 0)); + pComp->Value(mkNamingAdapt(Extinguisher, "Extinguisher", 0)); + pComp->Value(mkNamingAdapt(Soil, "Soil", 0)); + pComp->Value(mkNamingAdapt(Placement, "Placement", 0)); + pComp->Value(mkNamingAdapt(mkParAdapt(sTextureOverlay, StdCompiler::RCT_IdtfAllowEmpty), + "TextureOverlay", "")); + pComp->Value(mkNamingAdapt(OverlayType, "OverlayType", 0)); + pComp->Value(mkNamingAdapt(mkParAdapt(sPXSGfx, StdCompiler::RCT_IdtfAllowEmpty), + "PXSGfx", "")); + pComp->Value(mkNamingAdapt(PXSGfxRt, "PXSGfxRt", TargetRect0)); + pComp->Value(mkNamingAdapt(PXSGfxSize, "PXSGfxSize", PXSGfxRt.Wdt)); + pComp->Value(mkNamingAdapt(TempConvStrength, "TempConvStrength", 0)); + pComp->Value(mkNamingAdapt(mkParAdapt(sBlastShiftTo, StdCompiler::RCT_IdtfAllowEmpty), + "BlastShiftTo", "")); + pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvert, StdCompiler::RCT_IdtfAllowEmpty), + "InMatConvert", "")); + pComp->Value(mkNamingAdapt(mkParAdapt(sInMatConvertTo, StdCompiler::RCT_IdtfAllowEmpty), + "InMatConvertTo", "")); + pComp->Value(mkNamingAdapt(InMatConvertDepth, "InMatConvertDepth", 0)); + pComp->Value(mkNamingAdapt(AboveTempConvert, "AboveTempConvert", 0)); + pComp->Value(mkNamingAdapt(AboveTempConvertDir, "AboveTempConvertDir", 0)); + pComp->Value(mkNamingAdapt(mkParAdapt(sAboveTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty), + "AboveTempConvertTo", "")); + pComp->Value(mkNamingAdapt(BelowTempConvert, "BelowTempConvert", 0)); + pComp->Value(mkNamingAdapt(BelowTempConvertDir, "BelowTempConvertDir", 0)); + pComp->Value(mkNamingAdapt(mkParAdapt(sBelowTempConvertTo, StdCompiler::RCT_IdtfAllowEmpty), + "BelowTempConvertTo", "")); + pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0)); + pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10)); pComp->NameEnd(); // material reactions - pComp->Value(mkNamingAdapt( - mkSTLContainerAdapt(CustomReactionList), - "Reaction", std::vector())); + pComp->Value(mkNamingAdapt(mkSTLContainerAdapt(CustomReactionList), + "Reaction", std::vector())); } diff --git a/src/game/landscape/C4Material.h b/src/game/landscape/C4Material.h index 60353cbc1..26200c085 100644 --- a/src/game/landscape/C4Material.h +++ b/src/game/landscape/C4Material.h @@ -124,17 +124,27 @@ public: typedef std::map C4MaterialShapeMap; +enum C4MaterialCoreShape +{ + C4M_Flat = 0, + C4M_TopFlat = 1, + C4M_Smooth = 2, + C4M_Rough = 3, + C4M_Octagon = 4, + C4M_Smoother= 5, +}; + class C4MaterialCore { public: C4MaterialCore(); ~C4MaterialCore() { Clear(); } -public: std::vector CustomReactionList; -public: + char Name[C4M_MaxName+1]; - int32_t MapChunkType; + + C4MaterialCoreShape MapChunkType; StdCopyStrBuf ShapeTexture; int32_t Density; int32_t Friction; @@ -176,7 +186,7 @@ public: int32_t TempConvStrength; int32_t MinHeightCount; // minimum material thickness in order for it to be counted int32_t SplashRate; -public: + void Clear(); void Default(); bool Load(C4Group &hGroup, const char *szEntryName); @@ -248,13 +258,8 @@ protected: extern C4MaterialMap MaterialMap; -const int32_t C4M_Flat = 0, - C4M_TopFlat = 1, - C4M_Smooth = 2, - C4M_Rough = 3, - C4M_None = 4, - // Material Density Levels - C4M_Vehicle = 100, +// Material Density Levels +const int32_t C4M_Vehicle = 100, C4M_Solid = 50, C4M_SemiSolid = 25, C4M_Liquid = 25,