mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
revert portions to a previously demonstrated to work state...
This commit is contained in:
parent
329ffab86c
commit
315f05ea47
3 changed files with 15 additions and 54 deletions
|
|
@ -752,49 +752,22 @@ void ThermalErosionAction::process(Selection * sel, const Gui3DMouseEvent &, boo
|
||||||
// If this is the ending
|
// If this is the ending
|
||||||
// mouse down event, then
|
// mouse down event, then
|
||||||
// update the noise values.
|
// update the noise values.
|
||||||
U32 shift = getBinLog2(mNoiseSize);
|
if (type == Begin)
|
||||||
TerrainBlock* tblock = mTerrainEditor->getActiveTerrain();
|
|
||||||
if (!tblock)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mSelectionOrigin = Point2I(S32_MAX, S32_MAX);
|
|
||||||
|
|
||||||
F32 height = 0;
|
|
||||||
F32 maxHeight = 0;
|
|
||||||
U32 i = 0;
|
|
||||||
for (i=0; i < sel->size(); i++)
|
|
||||||
{
|
{
|
||||||
mSelectionOrigin.x = S32(mMin(F32((*sel)[i].mGridPoint.gridPos.x), F32(mSelectionOrigin.x)));
|
mNoise.setSeed(Sim::getCurrentTime());
|
||||||
mSelectionOrigin.y = S32(mMin(F32((*sel)[i].mGridPoint.gridPos.y), F32(mSelectionOrigin.y)));
|
mNoise.fBm(&mNoiseData, mNoiseSize, 12, 1.0f, 5.0f);
|
||||||
height = fixedToFloat(tblock->getHeight((*sel)[i].mGridPoint.gridPos));
|
Vector<F32> scratch = mNoiseData;
|
||||||
if (height > maxHeight)
|
mNoise.rigidMultiFractal(&mNoiseData, &scratch, mNoiseSize, 12, 1.0f, 5.0f);
|
||||||
maxHeight = height;
|
//erodeThermal(Vector<F32> *src, Vector<F32> *dst, F32 slope, F32 materialLoss, U32 iterations, U32 size, U32 squareSize, F32 maxHeight );
|
||||||
|
mNoise.erodeThermal(&mNoiseData, &mNoiseData, 30.0f, 5.0f, 5, mNoiseSize, 1, 2000.0f);
|
||||||
|
mNoise.getMinMax(&mNoiseData, &mMinMaxNoise.x, &mMinMaxNoise.y, mNoiseSize);
|
||||||
|
|
||||||
|
mScale = 1.5f / (mMinMaxNoise.x - mMinMaxNoise.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mTerrainHeights.size(); i++)
|
|
||||||
{
|
|
||||||
mTerrainHeights[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < sel->size(); i++)
|
|
||||||
{
|
|
||||||
mTerrainHeights[((*sel)[i].mGridPoint.gridPos.x - mSelectionOrigin.x) + (((*sel)[i].mGridPoint.gridPos.y - mSelectionOrigin.y) << shift)] = (*sel)[i].mHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
mNoise.setSeed(Sim::getCurrentTime());
|
|
||||||
//mNoise.fBm(&mNoiseData, mNoiseSize, 12, 1.0f, 5.0f);
|
|
||||||
//generate noise based on terrain hieghts
|
|
||||||
mNoise.rigidMultiFractal( &mNoiseData, &mTerrainHeights, mNoiseSize, 12, 1.0f, 5.0f );
|
|
||||||
//erode the noise
|
|
||||||
mNoise.erodeThermal(&mNoiseData, &mTerrainHeights, 45.0f, 0.5f, 12, mNoiseSize, 1, maxHeight);
|
|
||||||
|
|
||||||
mNoise.getMinMax(&mTerrainHeights, &mMinMaxNoise.x, &mMinMaxNoise.y, mNoiseSize);
|
|
||||||
mScale = (mMinMaxNoise.x - mMinMaxNoise.y) / maxHeight;
|
|
||||||
|
|
||||||
if (selChanged)
|
if (selChanged)
|
||||||
{
|
{
|
||||||
F32 heightDiff = 0;
|
for (U32 i = 0; i < sel->size(); i++)
|
||||||
for (i = 0; i < sel->size(); i++)
|
|
||||||
{
|
{
|
||||||
if (!isValid((*sel)[i]))
|
if (!isValid((*sel)[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -803,27 +776,21 @@ void ThermalErosionAction::process(Selection * sel, const Gui3DMouseEvent &, boo
|
||||||
|
|
||||||
const Point2I& gridPos = (*sel)[i].mGridPoint.gridPos;
|
const Point2I& gridPos = (*sel)[i].mGridPoint.gridPos;
|
||||||
|
|
||||||
// Need to get the height difference
|
const F32 noiseVal = mNoiseData[(gridPos.x % mNoiseSize) +
|
||||||
// between the current height and the
|
((gridPos.y % mNoiseSize) * mNoiseSize)];
|
||||||
// erosion height to properly apply the
|
|
||||||
// softness and pressure settings of the brush
|
|
||||||
// for this selection.
|
|
||||||
heightDiff = ((*sel)[i].mHeight - mTerrainHeights[(gridPos.x - mSelectionOrigin.x) + ((gridPos.y-mSelectionOrigin.y) << shift)]) * mScale;
|
|
||||||
|
|
||||||
(*sel)[i].mHeight += heightDiff * (*sel)[i].mWeight * mTerrainEditor->getBrushPressure();
|
(*sel)[i].mHeight -= (noiseVal - mMinMaxNoise.y * mScale) * (*sel)[i].mWeight * mTerrainEditor->mNoiseFactor;
|
||||||
|
|
||||||
if ((*sel)[i].mHeight > mTerrainEditor->mTileMaxHeight)
|
if ((*sel)[i].mHeight > mTerrainEditor->mTileMaxHeight)
|
||||||
(*sel)[i].mHeight = mTerrainEditor->mTileMaxHeight;
|
(*sel)[i].mHeight = mTerrainEditor->mTileMaxHeight;
|
||||||
|
|
||||||
if ((*sel)[i].mHeight < mTerrainEditor->mTileMinHeight)
|
if ((*sel)[i].mHeight < mTerrainEditor->mTileMinHeight)
|
||||||
(*sel)[i].mHeight = mTerrainEditor->mTileMinHeight;
|
(*sel)[i].mHeight = mTerrainEditor->mTileMinHeight;
|
||||||
|
|
||||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTerrainEditor->scheduleGridUpdate();
|
mTerrainEditor->scheduleGridUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HydraulicErosionAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
void HydraulicErosionAction::process(Selection* sel, const Gui3DMouseEvent&, bool selChanged, Type type)
|
||||||
|
|
|
||||||
|
|
@ -312,12 +312,8 @@ class ThermalErosionAction : public TerrainAction
|
||||||
{
|
{
|
||||||
mNoise.setSeed( 1 );//Sim::getCurrentTime() );
|
mNoise.setSeed( 1 );//Sim::getCurrentTime() );
|
||||||
mNoiseData.setSize(mNoiseSize * mNoiseSize);
|
mNoiseData.setSize(mNoiseSize * mNoiseSize);
|
||||||
mTerrainHeights.setSize(mNoiseSize * mNoiseSize);
|
|
||||||
mNoise.fBm(&mNoiseData, mNoiseSize, 12, 1.0f, 5.0f);
|
mNoise.fBm(&mNoiseData, mNoiseSize, 12, 1.0f, 5.0f);
|
||||||
//Vector<F32> scratch = mNoiseData;
|
|
||||||
//mNoise.rigidMultiFractal( &mNoiseData, &scratch, TerrainBlock::BlockSize, 12, 1.0f, 5.0f );
|
|
||||||
mNoise.getMinMax(&mNoiseData, &mMinMaxNoise.x, &mMinMaxNoise.y, mNoiseSize);
|
mNoise.getMinMax(&mNoiseData, &mMinMaxNoise.x, &mMinMaxNoise.y, mNoiseSize);
|
||||||
|
|
||||||
mScale = 1.5f / (mMinMaxNoise.x - mMinMaxNoise.y);
|
mScale = 1.5f / (mMinMaxNoise.x - mMinMaxNoise.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,9 +324,7 @@ class ThermalErosionAction : public TerrainAction
|
||||||
const U32 mNoiseSize;
|
const U32 mNoiseSize;
|
||||||
Noise2D mNoise;
|
Noise2D mNoise;
|
||||||
Vector<F32> mNoiseData;
|
Vector<F32> mNoiseData;
|
||||||
Vector<F32> mTerrainHeights;
|
|
||||||
Point2F mMinMaxNoise;
|
Point2F mMinMaxNoise;
|
||||||
Point2I mSelectionOrigin;
|
|
||||||
F32 mScale;
|
F32 mScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ bool Noise2D::erodeThermal(Vector<F32> *src, Vector<F32> *dst, F32 slope, F32 ma
|
||||||
//dMemset( r.address(), 0, r.memSize() );
|
//dMemset( r.address(), 0, r.memSize() );
|
||||||
|
|
||||||
F32 conservation = 1.0f - mClampF(materialLoss, 0.0f, 100.0f)/100.0f;
|
F32 conservation = 1.0f - mClampF(materialLoss, 0.0f, 100.0f)/100.0f;
|
||||||
slope = mMin(slope, mClampF(conservation, 0.0f, 89.0f)); // clamp to 0-89 degrees
|
slope = mClampF(conservation, 0.0f, 89.0f); // clamp to 0-89 degrees
|
||||||
|
|
||||||
F32 talusConst = mTan(mDegToRad(slope)) * squareSize; // in world units
|
F32 talusConst = mTan(mDegToRad(slope)) * squareSize; // in world units
|
||||||
talusConst = talusConst * (fmax-fmin) / maxHeight; // scale to current height units
|
talusConst = talusConst * (fmax-fmin) / maxHeight; // scale to current height units
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue