Merge pull request #2311 from Bloodknight/TerrainSnapOffsetZ

Snap to terrain Z offset.
This commit is contained in:
Areloch 2019-05-04 14:25:03 -05:00 committed by GitHub
commit 54b4d2eaaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View file

@ -819,6 +819,21 @@ void WorldEditor::terrainSnapSelection(Selection* sel, U8 modifier, Point3F gizm
{
mStuckToGround = true;
const F32 OffsetZValueMin = 0.01f;
if (mTerrainSnapOffsetZ)
{
if (mOffsetZValue == 0.0f)
{
ri.point.z += OffsetZValueMin;
}
else
{
ri.point.z += mOffsetZValue;
}
}
sel->offset(ri.point - centroid, (!mUseGroupCenter && mGridSnap) ? mGridPlaneSize : 0.f);
if(mTerrainSnapAlignment != AlignNone)
@ -1798,6 +1813,9 @@ WorldEditor::WorldEditor()
mStickToGround = false;
mStuckToGround = false;
mTerrainSnapAlignment = AlignNone;
mTerrainSnapOffsetZ = false;
mOffsetZValue = 0.0f;
mDropAtBounds = false;
mDropBelowCameraOffset = 15.0f;
mDropAtScreenCenterScalar = 1.0f;
@ -2791,6 +2809,8 @@ void WorldEditor::initPersistFields()
addField( "isDirty", TypeBool, Offset(mIsDirty, WorldEditor) );
addField( "stickToGround", TypeBool, Offset(mStickToGround, WorldEditor) );
addField("TerrainSnapOffsetZ", TypeBool, Offset(mTerrainSnapOffsetZ, WorldEditor));
addField("OffsetZValue", TypeF32, Offset(mOffsetZValue, WorldEditor));
//addField("sameScaleAllAxis", TypeBool, Offset(mSameScaleAllAxis, WorldEditor));
addField( "toggleIgnoreList", TypeBool, Offset(mToggleIgnoreList, WorldEditor) );

View file

@ -358,6 +358,8 @@ class WorldEditor : public EditTSCtrl
bool mStickToGround;
bool mStuckToGround; ///< Selection is stuck to the ground
AlignmentType mTerrainSnapAlignment; ///< How does the stickied object align to the terrain
bool mTerrainSnapOffsetZ; ///< Allows the use of an offset to avoid z-fighting with flat objects on a flat terrain.
F32 mOffsetZValue; ///< Value of the Z offset (note: this shouldnt be changed once set)
bool mSoftSnap; ///< Allow soft snapping all of the time
bool mSoftSnapActivated; ///< Soft snap has been activated by the user and allowed by the current rules