From 4f1aa7c5cf353c8952fa0c5fc424a3aba57f7d5f Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Tue, 5 Aug 2014 17:01:37 +0200 Subject: [PATCH] Destroy single pixels of non-diggable material [ala] --- planet/Material.ocg/Vehicle.ocm | 2 +- src/landscape/C4Landscape.cpp | 8 +++++--- src/landscape/C4Material.cpp | 2 ++ src/landscape/C4Material.h | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/planet/Material.ocg/Vehicle.ocm b/planet/Material.ocg/Vehicle.ocm index 3d078e365..43e981e19 100644 --- a/planet/Material.ocg/Vehicle.ocm +++ b/planet/Material.ocg/Vehicle.ocm @@ -2,4 +2,4 @@ Name=Vehicle Density=100 Friction=100 - +KeepSinglePixels=1 diff --git a/src/landscape/C4Landscape.cpp b/src/landscape/C4Landscape.cpp index f9dda50b4..baaa63067 100644 --- a/src/landscape/C4Landscape.cpp +++ b/src/landscape/C4Landscape.cpp @@ -756,14 +756,16 @@ bool C4Landscape::CheckInstability(int32_t tx, int32_t ty, int32_t recursion_cou { int32_t mat=GetMat(tx,ty); if (MatValid(mat)) { - if (::MaterialMap.Map[mat].Instable) + const C4Material &material = MaterialMap.Map[mat]; + if (material.Instable) return ::MassMover.Create(tx,ty); // Get rid of single pixels - else if (::MaterialMap.Map[mat].DigFree && recursion_count<10) + else if (DensitySolid(material.Density) && !material.KeepSinglePixels && recursion_count<10) if ((!::GBackSolid(tx,ty+1)) + (!::GBackSolid(tx,ty-1)) + (!::GBackSolid(tx+1,ty)) + (!::GBackSolid(tx-1,ty)) >= 3) { if (!ClearPix(tx,ty)) return false; - ::PXS.Create(mat,itofix(tx),itofix(ty)); + // Diggable material drops; other material just gets removed + if (material.DigFree) ::PXS.Create(mat,itofix(tx),itofix(ty)); // check other pixels around this // Note this cannot lead to an endless recursion (unless you do funny stuff like e.g. set DigFree=1 in material Tunnel). // Check recursion anyway, because very large strips of single pixel width might cause sufficient recursion to crash diff --git a/src/landscape/C4Material.cpp b/src/landscape/C4Material.cpp index 469a8b06e..5419e5b08 100644 --- a/src/landscape/C4Material.cpp +++ b/src/landscape/C4Material.cpp @@ -265,6 +265,7 @@ void C4MaterialCore::Clear() TempConvStrength = 0; MinHeightCount = 0; SplashRate=10; + KeepSinglePixels=false; } void C4MaterialCore::Default() @@ -364,6 +365,7 @@ void C4MaterialCore::CompileFunc(StdCompiler *pComp) "BelowTempConvertTo", "")); pComp->Value(mkNamingAdapt(MinHeightCount, "MinHeightCount", 0)); pComp->Value(mkNamingAdapt(SplashRate, "SplashRate", 10)); + pComp->Value(mkNamingAdapt(KeepSinglePixels, "KeepSinglePixels", false)); pComp->NameEnd(); // material reactions pComp->Value(mkNamingAdapt(mkSTLContainerAdapt(CustomReactionList), diff --git a/src/landscape/C4Material.h b/src/landscape/C4Material.h index 45e60febb..b8cc0a28d 100644 --- a/src/landscape/C4Material.h +++ b/src/landscape/C4Material.h @@ -178,6 +178,7 @@ public: int32_t TempConvStrength; int32_t MinHeightCount; // minimum material thickness in order for it to be counted int32_t SplashRate; + bool KeepSinglePixels; // if true, single pixels are not destroyed (for vehicle) void Clear(); void Default();