Skip to content

Commit

Permalink
* FIX:[LE] Поченил гизмо на разных тулах
Browse files Browse the repository at this point in the history
  • Loading branch information
BearIvan committed Jun 11, 2022
1 parent 1b5260b commit 711ac04
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 51 deletions.
6 changes: 3 additions & 3 deletions Source/Editors/LevelEditor/Editor/Entry/CustomObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ class CCustomObject:private pureDrawUI
virtual void NumSetRotation (const Fvector& rot) { SetRotation(rot); }
virtual void NumSetScale (const Fvector& scale) { SetScale(scale); }
virtual void MoveTo (const Fvector& pos, const Fvector& up);
virtual void Move (Fvector& amount);
virtual void Move (Fvector& Position);
virtual void RotateParent (Fvector& axis, float angle );
virtual void RotateLocal (Fvector& axis, float angle );
virtual void RotatePivot (const Fmatrix& prev_inv, const Fmatrix& current);
virtual void Scale (Fvector& amount);
virtual void Scale (Fvector& NewScale);
virtual void ScalePivot (const Fmatrix& prev_inv, const Fmatrix& current, Fvector& amount);

virtual bool LoadStream (IReader&);
Expand Down Expand Up @@ -227,7 +227,7 @@ class CCustomObject:private pureDrawUI
IC const Fvector& GetSaveScale (){return EScaleSaved;}
IC void RotateSave (){ERotateSaved = FRotation;}
IC const Fvector& GetSaveRotate (){return ERotateSaved;}
IC void PositionSave () { EPositionSaved = FPosition; }
virtual void PositionSave () { EPositionSaved = FPosition; }
IC const Fvector& GetSavePosition () { return EPositionSaved; }

ObjClassID FClassID;
Expand Down
25 changes: 5 additions & 20 deletions Source/Editors/LevelEditor/Editor/Entry/CustomObjectLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,10 @@ void CCustomObject::OnAttach(CCustomObject* owner)
FParentTools->SetChanged(TRUE);
}

void CCustomObject::Move(Fvector& amount)
void CCustomObject::Move(Fvector& Position)
{
UI->UpdateScene();
Fvector v=GetPosition();
Fvector r=FRotation;
if (Tools->GetSettings(etfMTSnap)){
BOOL bVis = Visible();
BOOL bSel = Selected();
Show (FALSE);
Select (FALSE);
SnapMove (v,r,FTransformRP,amount);
Show (bVis);
Select (bSel);
}else{
v.add(amount);
}
SetPosition(v);
FRotation = r;
SetPosition(Position);
}

void CCustomObject::MoveTo(const Fvector& pos, const Fvector& up)
Expand Down Expand Up @@ -142,7 +128,7 @@ void CCustomObject::ScalePivot( const Fmatrix& prev_inv, const Fmatrix& current,
{
UI->UpdateScene();
Fvector p = GetPosition();
Fvector s = GetScale();;
Fvector s = GetSaveScale();;
s.add(amount);
if (s.x<EPS) s.x=EPS;
if (s.y<EPS) s.y=EPS;
Expand All @@ -156,11 +142,10 @@ void CCustomObject::ScalePivot( const Fmatrix& prev_inv, const Fmatrix& current,
SetPosition( p);
}

void CCustomObject::Scale( Fvector& amount )
void CCustomObject::Scale( Fvector& Scale )
{
UI->UpdateScene();
Fvector s = GetScale();
s.add(amount);
Fvector s = Scale;
if (s.x<EPS) s.x=EPS;
if (s.y<EPS) s.y=EPS;
if (s.z<EPS) s.z=EPS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,11 @@ void CGroupObject::RotateLocal(Fvector& axis, float angle )
}
}

void CGroupObject::Scale(Fvector& amount )
void CGroupObject::Scale(Fvector& scale )
{
inherited::Scale(amount);
inherited::Scale(scale);
Fvector amount;
amount.sub(scale, GetSaveScale());
Fmatrix m_old;
m_old.invert(FTransform);
UpdateTransform(true);
Expand Down
3 changes: 0 additions & 3 deletions Source/Editors/LevelEditor/Editor/Entry/Spawn/SpawnPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,6 @@ void CSpawnPoint::Select(int flag)
void CSpawnPoint::Move( Fvector& amount )
{
inherited::Move( amount );
const float f_drag_factor = 200.f;
if(m_physics_shell)
ApplyDragForce( Fvector().mul(amount,f_drag_factor) );
}

void CSpawnPoint::SetPosition(const Fvector& pos)
Expand Down
38 changes: 33 additions & 5 deletions Source/Editors/LevelEditor/Editor/Entry/WayPoint/WayPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,19 @@ void CWayObject::MoveTo(const Fvector& pos, const Fvector& up)
}
}

void CWayObject::Move(Fvector& amount)
void CWayObject::Move(Fvector& Position)
{
if (IsPointMode()){
Fvector Delta;
Delta.sub(Position, GetSavePosition());
if (IsPointMode())
{
for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++)
if ((*it)->m_bSelected) (*it)->m_vPosition.add(amount);
}else{
if ((*it)->m_bSelected) (*it)->m_vPosition.add(Delta, (*it)->m_vSavePosition);
}
else
{
for (WPIt it=m_WayPoints.begin(); it!=m_WayPoints.end(); it++)
(*it)->m_vPosition.add(amount);
(*it)->m_vPosition.add(Delta, (*it)->m_vSavePosition);
}
}

Expand Down Expand Up @@ -812,4 +817,27 @@ bool CWayObject::OnSelectionRemove()
}else return true;
}

void CWayObject::PositionSave()
{
CCustomObject::PositionSave();
if (IsPointMode())
{
for (WPIt it = m_WayPoints.begin(); it != m_WayPoints.end(); it++)
{
if ((*it)->m_bSelected)
{
(*it)->m_vSavePosition = (*it)->m_vPosition;
}
}
}
else
{
for (WPIt it = m_WayPoints.begin(); it != m_WayPoints.end(); it++)
{

(*it)->m_vSavePosition = (*it)->m_vPosition;
}
}
}


9 changes: 7 additions & 2 deletions Source/Editors/LevelEditor/Editor/Entry/WayPoint/WayPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ DEFINE_VECTOR(SWPLink*,WPLVec,WPLIt);
class CWayPoint
{

friend class Gizmo;
friend class CPatrolPoint;
friend class CPatrolPath;
friend class CWayObject;
friend class TfrmPropertiesWayPoint;
shared_str m_Name;
Fvector m_vPosition;
Fvector m_vPosition;
Fvector m_vSavePosition;
Flags32 m_Flags;
BOOL m_bSelected;
WPLVec m_Links;
Expand Down Expand Up @@ -53,7 +55,8 @@ class CWayObject: public CCustomObject
protected:
friend class TfrmPropertiesWayPoint;
friend class CPatrolPath;
friend class CPatrolPoint;
friend class CPatrolPoint;
friend class Gizmo;
EWayType m_Type;
WPVec m_WayPoints;
typedef CCustomObject inherited;
Expand Down Expand Up @@ -110,4 +113,6 @@ class CWayObject: public CCustomObject

virtual const Fvector& GetPosition () const { return m_WayPoints.front()->m_vPosition; }
virtual void SetPosition (const Fvector& pos) { MoveTo(pos, Fvector().set(0,1,0) ); UpdateTransform();}

virtual void PositionSave();
};
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void TUI_CustomControl::MoveProcess(Fvector Delta, Fvector Vector)
{
Pos.z = snapto(Pos.z, LTools->GetGimzo()->GetStep(Gizmo::EType::Move));
}
Obj->SetPosition(Pos);
Obj->Move(Pos);
Tools->UpdateProperties();
}
}
Expand All @@ -151,6 +151,22 @@ void TUI_CustomControl::ScaleProcess(Fvector Delta, Fvector Vector)
for (CCustomObject* Obj : lst)
{
Fvector Pos = Obj->GetSaveScale();
if (Obj->FClassID == OBJCLASS_GLOW)
{
if (LTools->GetGimzo()->GetStatus() == Gizmo::EStatus::SelectedX)
{
Delta.set(Delta.x, Delta.x, Delta.x);
}
if (LTools->GetGimzo()->GetStatus() == Gizmo::EStatus::SelectedY)
{
Delta.set(Delta.y, Delta.y, Delta.y);
}
if (LTools->GetGimzo()->GetStatus() == Gizmo::EStatus::SelectedZ)
{
Delta.set(Delta.z, Delta.z, Delta.z);
}
Vector.set(1, 1, 1);
}
Pos.mad(Delta, Vector);
if (LTools->GetGimzo()->IsStepEnable(Gizmo::EType::Scale) && abs(Vector.x) > EPS)
{
Expand All @@ -176,7 +192,7 @@ void TUI_CustomControl::ScaleProcess(Fvector Delta, Fvector Vector)
{
Pos.z = EPS;
}
Obj->SetScale(Pos);
Obj->Scale(Pos);
Tools->UpdateProperties();
}
}
Expand Down Expand Up @@ -435,7 +451,7 @@ void TUI_CustomControl::SelectProcess(TShiftState _Shift)
Fvector Delta;
Delta.set(1, 1, 1).mul(((Position.x - StartPosition.x) + (Position.y - StartPosition.y) + (Position.z - StartPosition.z)) * 0.7f);

ScaleProcess(Delta, Fvector().set(0, 1, 0));
ScaleProcess(Delta, Fvector().set(1, 1, 1));
}
}
/* else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class ESceneToolBase
void UpdateControl ();
public:
void SetAction (int action);
void SetSubTarget (int target);
void SetSubTarget(int target);
IC int GetSubTarget(int target) const { return sub_target; }
void ResetSubTarget ();
protected:
void CreateDefaultControls (u32 sub_target_id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#include "stdafx.h"

class TUI_ControlGlowSelect : public TUI_CustomControl
{
public:
TUI_ControlGlowSelect(int st, int act, ESceneToolBase* parent) :TUI_CustomControl(st, act, parent) {}
virtual bool IsSupportRotate() { return false; }
};

void ESceneGlowTool::CreateControls()
{
inherited::CreateDefaultControls(estDefault);
AddControl(xr_new<TUI_ControlGlowSelect>(estDefault, etaSelect, this));
m_Flags.zero ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,17 @@ bool ESceneLightTool::Validate(bool full_test)
}
return bRes;
}

class TUI_ControlLightToolsSelect : public TUI_CustomControl
{
public:
TUI_ControlLightToolsSelect(int st, int act, ESceneToolBase* parent) :TUI_CustomControl(st, act, parent) {}
virtual bool IsSupportRotate() { return false; }
virtual bool IsSupportScale() { return false; }
};
void ESceneLightTool::CreateControls()
{
inherited::CreateDefaultControls(estDefault);
AddControl(xr_new<TUI_ControlLightToolsSelect>(estDefault, etaSelect, this));
// frame
pForm = xr_new<UILightTool>();
// pFrame = xr_new<TfraLight>((TComponent*)0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#pragma once

class TUI_ControlPSToolsSelect : public TUI_CustomControl
{
public:
TUI_ControlPSToolsSelect(int st, int act, ESceneToolBase* parent) :TUI_CustomControl(st, act, parent) {}
virtual bool IsSupportRotate() { return false; }
virtual bool IsSupportScale() { return false; }
};
class TUI_ControlPSAdd: public TUI_CustomControl
{
bool AfterAppendCallback(TShiftState Shift, CCustomObject* obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

void EScenePSTool::CreateControls()
{
inherited::CreateDefaultControls(estDefault);
AddControl (xr_new<TUI_ControlPSAdd>(estDefault,etaAdd, this));
inherited::CreateDefaultControls(estDefault);

AddControl(xr_new<TUI_ControlPSAdd>(estDefault, etaAdd, this));
AddControl(xr_new<TUI_ControlPSToolsSelect>(estDefault, etaSelect, this));
// frame
pForm = xr_new< UIParticlesTool>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include "stdafx.h"

class TUI_ControlSoundSrcTool : public TUI_CustomControl
{
public:
TUI_ControlSoundSrcTool(int st, int act, ESceneToolBase* parent) :TUI_CustomControl(st, act, parent) {}
virtual bool IsSupportRotate() { return false; }
virtual bool IsSupportScale() { return false; }
};
void ESceneSoundSrcTool::CreateControls()
{
inherited::CreateDefaultControls(estDefault);
AddControl(xr_new<TUI_ControlSoundSrcTool>(estDefault, etaSelect, this));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ void ESceneWayTool::CreateControls()
{
inherited::CreateDefaultControls(estWayModeWay);
inherited::CreateDefaultControls(estWayModePoint);
AddControl (xr_new<TUI_ControlWayPointAdd> (estWayModePoint, etaAdd, this));
AddControl(xr_new<TUI_ControlWayPointAdd>(estWayModePoint, etaAdd, this));
AddControl(xr_new<TUI_ControlWayPointSelect>(estDefault, etaSelect, this));
AddControl(xr_new<TUI_ControlWayPointSelect>(estWayModePoint, etaSelect, this));
// frame
pForm = xr_new< UIWayTool>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ class TUI_ControlWayPointAdd: public TUI_CustomControl
virtual ~TUI_ControlWayPointAdd(){;}
virtual bool Start (TShiftState _Shift);
virtual void OnEnter();
};

class TUI_ControlWayPointSelect : public TUI_CustomControl
{
public:
TUI_ControlWayPointSelect(int st, int act, ESceneToolBase* parent) :TUI_CustomControl(st, act, parent) {}
virtual bool IsSupportRotate() { return false; }
virtual bool IsSupportScale() { return false; }
};
34 changes: 28 additions & 6 deletions Source/Editors/LevelEditor/Editor/Utils/Gimzo/Gizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void Gizmo::OnFrame()
}
Fbox Box; Box.invalidate();
size_t SelectedCount = 0;
bool bIsPointMode = LTools->GetSubTarget() == estWayModePoint;
if (OBJCLASS_AIMAP == LTools->CurrentClassID())
{
if (m_Type == EType::Scale)
Expand Down Expand Up @@ -162,14 +163,35 @@ void Gizmo::OnFrame()
for (auto& Object : ObjectTool->GetObjects())
{
if (!Object->Selected())continue;
m_Position = Object->GetPosition();
m_RotateMatrix.setXYZ(Object->GetRotation());
Fbox ObjectBox;
if (Object->GetBox(ObjectBox))
if (bIsPointMode&& Object->FClassID == OBJCLASS_WAY)
{
Box.merge(ObjectBox);
CWayObject* Way = (CWayObject*)Object;
for (WPIt it = Way->m_WayPoints.begin(); it != Way->m_WayPoints.end(); it++)
{
if ((*it)->m_bSelected)
{
m_Position = (*it)->m_vPosition;
m_RotateMatrix.identity();
Fbox ObjectBox;
(*it)->GetBox(ObjectBox);
Box.merge(ObjectBox);
SelectedCount++;
}
}

}
SelectedCount++;
else
{
m_Position = Object->GetPosition();
m_RotateMatrix.setXYZ(Object->GetRotation());
Fbox ObjectBox;
if (Object->GetBox(ObjectBox))
{
Box.merge(ObjectBox);
}
SelectedCount++;
}

}
}
}
Expand Down

0 comments on commit 711ac04

Please sign in to comment.