mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 13:30:34 +00:00
add min/max tile height entrys to painter, apply those to the general isvalid check for a given tile alteration. apply that to more brushes.
This commit is contained in:
parent
85955479c8
commit
24933a1cc7
6 changed files with 330 additions and 50 deletions
|
|
@ -51,6 +51,9 @@ bool TerrainAction::isValid(GridInfo tile)
|
|||
norm.z < maxSlope)
|
||||
return false;
|
||||
}
|
||||
if (tile.mHeight < mTerrainEditor->mTileMinHeight || tile.mHeight > mTerrainEditor->mTileMaxHeight)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -226,32 +229,13 @@ void PaintMaterialAction::process(Selection * sel, const Gui3DMouseEvent &, bool
|
|||
if ( !selChanged || mat < 0 )
|
||||
return;
|
||||
|
||||
const bool slopeLimit = mTerrainEditor->mSlopeMinAngle > 0.0f || mTerrainEditor->mSlopeMaxAngle < 90.0f;
|
||||
const F32 minSlope = mSin( mDegToRad( 90.0f - mTerrainEditor->mSlopeMinAngle ) );
|
||||
const F32 maxSlope = mSin( mDegToRad( 90.0f - mTerrainEditor->mSlopeMaxAngle ) );
|
||||
|
||||
const TerrainBlock *terrain = mTerrainEditor->getActiveTerrain();
|
||||
const F32 squareSize = terrain->getSquareSize();
|
||||
|
||||
Point2F p;
|
||||
Point3F norm;
|
||||
|
||||
|
||||
for( U32 i = 0; i < sel->size(); i++ )
|
||||
{
|
||||
GridInfo &inf = (*sel)[i];
|
||||
|
||||
if ( slopeLimit )
|
||||
{
|
||||
p.x = inf.mGridPoint.gridPos.x * squareSize;
|
||||
p.y = inf.mGridPoint.gridPos.y * squareSize;
|
||||
if ( !terrain->getNormal( p, &norm, true ) )
|
||||
continue;
|
||||
|
||||
if ( norm.z > minSlope ||
|
||||
norm.z < maxSlope )
|
||||
continue;
|
||||
}
|
||||
if (!isValid(inf))
|
||||
continue;
|
||||
|
||||
// If grid is already set to our material, or it is an
|
||||
// empty grid spot, then skip painting.
|
||||
|
|
@ -324,6 +308,9 @@ void RaiseHeightAction::process( Selection *sel, const Gui3DMouseEvent &evt, boo
|
|||
|
||||
for ( U32 i = 0; i < sel->size(); i++ )
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
if ( (*sel)[i].mHeight < maxHeight )
|
||||
{
|
||||
|
|
@ -370,6 +357,9 @@ void LowerHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool s
|
|||
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
if((*sel)[i].mHeight > maxHeight)
|
||||
{
|
||||
|
|
@ -391,6 +381,9 @@ void SetHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool sel
|
|||
{
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
(*sel)[i].mHeight = mTerrainEditor->mSetHeightVal;
|
||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||
|
|
@ -470,6 +463,9 @@ void ScaleHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool s
|
|||
{
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
(*sel)[i].mHeight *= mTerrainEditor->mScaleVal;
|
||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||
|
|
@ -529,6 +525,9 @@ void BrushAdjustHeightAction::process(Selection * sel, const Gui3DMouseEvent & e
|
|||
// and record the starting heights
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
(*sel)[i].mStartHeight = (*sel)[i].mHeight;
|
||||
}
|
||||
|
|
@ -608,6 +607,9 @@ void FlattenHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool
|
|||
// set it
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
|
||||
//
|
||||
|
|
@ -652,6 +654,9 @@ void SmoothHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool
|
|||
// linear
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
(*sel)[i].mHeight += (avgHeight - (*sel)[i].mHeight) * mTerrainEditor->mSmoothFactor * (*sel)[i].mWeight;
|
||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||
}
|
||||
|
|
@ -695,7 +700,10 @@ void SmoothSlopeAction::process(Selection * sel, const Gui3DMouseEvent &, bool s
|
|||
|
||||
F32 goalHeight;
|
||||
for(U32 i = 0; i < sel->size(); i++)
|
||||
{
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
goalHeight = avgHeight + ((*sel)[i].mGridPoint.gridPos.x - avgPos.x)*avgSlope.x +
|
||||
((*sel)[i].mGridPoint.gridPos.y - avgPos.y)*avgSlope.y;
|
||||
(*sel)[i].mHeight += (goalHeight - (*sel)[i].mHeight) * (*sel)[i].mWeight;
|
||||
|
|
@ -723,6 +731,9 @@ void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool se
|
|||
{
|
||||
for( U32 i = 0; i < sel->size(); i++ )
|
||||
{
|
||||
if (!isValid((*sel)[i]))
|
||||
continue;
|
||||
|
||||
mTerrainEditor->getUndoSel()->add((*sel)[i]);
|
||||
|
||||
const Point2I &gridPos = (*sel)[i].mGridPoint.gridPos;
|
||||
|
|
@ -732,6 +743,12 @@ void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool se
|
|||
|
||||
(*sel)[i].mHeight += (noiseVal - mMinMaxNoise.y * mScale) * (*sel)[i].mWeight * mTerrainEditor->mNoiseFactor;
|
||||
|
||||
if ((*sel)[i].mHeight > mTerrainEditor->mTileMaxHeight)
|
||||
(*sel)[i].mHeight = mTerrainEditor->mTileMaxHeight;
|
||||
|
||||
if ((*sel)[i].mHeight < mTerrainEditor->mTileMinHeight)
|
||||
(*sel)[i].mHeight = mTerrainEditor->mTileMinHeight;
|
||||
|
||||
mTerrainEditor->setGridInfo((*sel)[i]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue