Code/Editor

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-09-10 20:15:16 -07:00
parent 8554cea0ad
commit 7f157f152d
39 changed files with 524 additions and 524 deletions
+9 -9
View File
@@ -35,21 +35,21 @@ public:
//////////////////////////////////////////////////////////////////////////
// Ovverides from CGizmo
//////////////////////////////////////////////////////////////////////////
virtual void GetWorldBounds(AABB& bbox);
virtual void Display(DisplayContext& dc);
virtual bool HitTest(HitContext& hc);
virtual const Matrix34& GetMatrix() const;
void GetWorldBounds(AABB& bbox) override;
void Display(DisplayContext& dc) override;
bool HitTest(HitContext& hc) override;
const Matrix34& GetMatrix() const override;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// ITransformManipulator implementation.
//////////////////////////////////////////////////////////////////////////
virtual Matrix34 GetTransformation(RefCoordSys coordSys, IDisplayViewport* view = nullptr) const;
virtual void SetTransformation(RefCoordSys coordSys, const Matrix34& tm);
virtual bool HitTestManipulator(HitContext& hc);
virtual bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int nFlags);
virtual void SetAlwaysUseLocal(bool on)
Matrix34 GetTransformation(RefCoordSys coordSys, IDisplayViewport* view = nullptr) const override;
void SetTransformation(RefCoordSys coordSys, const Matrix34& tm) override;
bool HitTestManipulator(HitContext& hc) override;
bool MouseCallback(CViewport* view, EMouseEvent event, QPoint& point, int nFlags) override;
void SetAlwaysUseLocal(bool on) override
{ m_bAlwaysUseLocal = on; }
//////////////////////////////////////////////////////////////////////////
+1 -1
View File
@@ -712,7 +712,7 @@ protected:
// May be overridden in derived classes to handle helpers scaling.
//////////////////////////////////////////////////////////////////////////
virtual void SetHelperScale([[maybe_unused]] float scale) {};
virtual float GetHelperScale() { return 1; };
virtual float GetHelperScale() { return 1.0f; };
void SetNameInternal(const QString& name) { m_name = name; }
+27 -27
View File
@@ -82,14 +82,14 @@ public:
// Overrides from CBaseObject.
//////////////////////////////////////////////////////////////////////////
//! Return type name of Entity.
QString GetTypeDescription() const { return GetEntityClass(); };
QString GetTypeDescription() const override { return GetEntityClass(); };
//////////////////////////////////////////////////////////////////////////
bool IsSameClass(CBaseObject* obj);
bool IsSameClass(CBaseObject* obj) override;
virtual bool Init(IEditor* ie, CBaseObject* prev, const QString& file);
virtual void InitVariables();
virtual void Done();
bool Init(IEditor* ie, CBaseObject* prev, const QString& file) override;
void InitVariables() override;
void Done() override;
void DrawExtraLightInfo (DisplayContext& disp);
@@ -102,30 +102,30 @@ public:
void SetEntityPropertyFloat(const char* name, float value);
void SetEntityPropertyString(const char* name, const QString& value);
virtual int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags);
virtual void OnContextMenu(QMenu* menu);
int MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) override;
void OnContextMenu(QMenu* menu) override;
void SetName(const QString& name);
void SetSelected(bool bSelect);
void SetName(const QString& name) override;
void SetSelected(bool bSelect) override;
virtual void GetLocalBounds(AABB& box);
void GetLocalBounds(AABB& box) override;
virtual bool HitTest(HitContext& hc);
virtual bool HitHelperTest(HitContext& hc);
virtual bool HitTestRect(HitContext& hc);
void UpdateVisibility(bool bVisible);
bool ConvertFromObject(CBaseObject* object);
bool HitTest(HitContext& hc) override;
bool HitHelperTest(HitContext& hc) override;
bool HitTestRect(HitContext& hc) override;
void UpdateVisibility(bool bVisible) override;
bool ConvertFromObject(CBaseObject* object) override;
using CBaseObject::Serialize;
void Serialize(CObjectArchive& ar) override;
virtual void PostLoad(CObjectArchive& ar);
void PostLoad(CObjectArchive& ar) override;
XmlNodeRef Export(const QString& levelPath, XmlNodeRef& xmlNode);
XmlNodeRef Export(const QString& levelPath, XmlNodeRef& xmlNode) override;
//////////////////////////////////////////////////////////////////////////
void OnEvent(ObjectEvent event);
void OnEvent(ObjectEvent event) override;
virtual void SetTransformDelegate(ITransformDelegate* pTransformDelegate) override;
void SetTransformDelegate(ITransformDelegate* pTransformDelegate) override;
// Set attach flags and target
enum EAttachmentType
@@ -140,15 +140,15 @@ public:
EAttachmentType GetAttachType() const { return m_attachmentType; }
QString GetAttachTarget() const { return m_attachmentTarget; }
virtual void SetHelperScale(float scale);
virtual float GetHelperScale();
void SetHelperScale(float scale) override;
float GetHelperScale() override;
virtual void GatherUsedResources(CUsedResources& resources);
virtual bool IsSimilarObject(CBaseObject* pObject);
void GatherUsedResources(CUsedResources& resources) override;
bool IsSimilarObject(CBaseObject* pObject) override;
virtual bool HasMeasurementAxis() const { return false; }
bool HasMeasurementAxis() const override { return false; }
virtual bool IsIsolated() const { return false; }
bool IsIsolated() const override { return false; }
//////////////////////////////////////////////////////////////////////////
// END CBaseObject
@@ -233,7 +233,7 @@ protected:
//////////////////////////////////////////////////////////////////////////
//! Must be called after cloning the object on clone of object.
//! This will make sure object references are cloned correctly.
virtual void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx);
void PostClone(CBaseObject* pFromObject, CObjectCloneContext& ctx) override;
//! Draw default object items.
void DrawProjectorPyramid(DisplayContext& dc, float dist);
@@ -265,7 +265,7 @@ public:
}
protected:
void DeleteThis() { delete this; };
void DeleteThis() override { delete this; };
//////////////////////////////////////////////////////////////////////////
// Radius callbacks.
+4 -4
View File
@@ -23,14 +23,14 @@ class CGizmoManager
: public IGizmoManager
{
public:
void AddGizmo(CGizmo* gizmo);
void RemoveGizmo(CGizmo* gizmo);
void AddGizmo(CGizmo* gizmo) override;
void RemoveGizmo(CGizmo* gizmo) override;
int GetGizmoCount() const override;
CGizmo* GetGizmoByIndex(int nIndex) const override;
void Display(DisplayContext& dc);
bool HitTest(HitContext& hc);
void Display(DisplayContext& dc) override;
bool HitTest(HitContext& hc) override;
void DeleteAllTransformManipulators();
+4 -4
View File
@@ -30,10 +30,10 @@ public:
//////////////////////////////////////////////////////////////////////////
// Ovverides from CGizmo
//////////////////////////////////////////////////////////////////////////
virtual void SetName(const char* sName);
virtual void GetWorldBounds(AABB& bbox);
virtual void Display(DisplayContext& dc);
virtual bool HitTest(HitContext& hc);
void SetName(const char* sName) override;
void GetWorldBounds(AABB& bbox) override;
void Display(DisplayContext& dc) override;
bool HitTest(HitContext& hc) override;
//////////////////////////////////////////////////////////////////////////
void SetObjects(CBaseObject* pObject1, CBaseObject* pObject2, const QString& boneName = "");
+74 -74
View File
@@ -103,142 +103,142 @@ public:
void RegisterObjectClasses();
CBaseObject* NewObject(CObjectClassDesc* cls, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr);
CBaseObject* NewObject(const QString& typeName, CBaseObject* prev = 0, const QString& file = "", const char* newEntityName = nullptr);
CBaseObject* NewObject(CObjectClassDesc* cls, CBaseObject* prev = 0, const QString& file = "", const char* newObjectName = nullptr) override;
CBaseObject* NewObject(const QString& typeName, CBaseObject* prev = 0, const QString& file = "", const char* newEntityName = nullptr) override;
void DeleteObject(CBaseObject* obj);
void DeleteSelection(CSelectionGroup* pSelection);
void DeleteAllObjects();
CBaseObject* CloneObject(CBaseObject* obj);
void DeleteObject(CBaseObject* obj) override;
void DeleteSelection(CSelectionGroup* pSelection) override;
void DeleteAllObjects() override;
CBaseObject* CloneObject(CBaseObject* obj) override;
void BeginEditParams(CBaseObject* obj, int flags);
void EndEditParams(int flags = 0);
void BeginEditParams(CBaseObject* obj, int flags) override;
void EndEditParams(int flags = 0) override;
// Hides all transform manipulators.
void HideTransformManipulators();
//! Get number of objects manager by ObjectManager (not contain sub objects of groups).
int GetObjectCount() const;
int GetObjectCount() const override;
//! Get array of objects, managed by manager (not contain sub objects of groups).
//! @param layer if 0 get objects for all layers, or layer to get objects from.
void GetObjects(CBaseObjectsArray& objects) const;
void GetObjects(CBaseObjectsArray& objects) const override;
//! Get array of objects that pass the filter.
//! @param filter The filter functor, return true if you want to get the certain obj, return false if want to skip it.
void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const;
void GetObjects(CBaseObjectsArray& objects, BaseObjectFilterFunctor const& filter) const override;
//! Update objects.
void Update();
//! Display objects on display context.
void Display(DisplayContext& dc);
void Display(DisplayContext& dc) override;
//! Called when selecting without selection helpers - this is needed since
//! the visible object cache is normally not updated when not displaying helpers.
void ForceUpdateVisibleObjectCache(DisplayContext& dc);
void ForceUpdateVisibleObjectCache(DisplayContext& dc) override;
//! Check intersection with objects.
//! Find intersection with nearest to ray origin object hit by ray.
//! If distance tollerance is specified certain relaxation applied on collision test.
//! @return true if hit any object, and fills hitInfo structure.
bool HitTest(HitContext& hitInfo);
bool HitTest(HitContext& hitInfo) override;
//! Check intersection with an object.
//! @return true if hit, and fills hitInfo structure.
bool HitTestObject(CBaseObject* obj, HitContext& hc);
bool HitTestObject(CBaseObject* obj, HitContext& hc) override;
//! Send event to all objects.
//! Will cause OnEvent handler to be called on all objects.
void SendEvent(ObjectEvent event);
void SendEvent(ObjectEvent event) override;
//! Send event to all objects within given bounding box.
//! Will cause OnEvent handler to be called on objects within bounding box.
void SendEvent(ObjectEvent event, const AABB& bounds);
void SendEvent(ObjectEvent event, const AABB& bounds) override;
//////////////////////////////////////////////////////////////////////////
//! Find object by ID.
CBaseObject* FindObject(REFGUID guid) const;
CBaseObject* FindObject(REFGUID guid) const override;
//////////////////////////////////////////////////////////////////////////
//! Find object by name.
CBaseObject* FindObject(const QString& sName) const;
CBaseObject* FindObject(const QString& sName) const override;
//////////////////////////////////////////////////////////////////////////
//! Find objects of given type.
void FindObjectsOfType(const QMetaObject* pClass, std::vector<CBaseObject*>& result) override;
void FindObjectsOfType(ObjectType type, std::vector<CBaseObject*>& result) override;
//////////////////////////////////////////////////////////////////////////
//! Find objects which intersect with a given AABB.
virtual void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const;
void FindObjectsInAABB(const AABB& aabb, std::vector<CBaseObject*>& result) const override;
//////////////////////////////////////////////////////////////////////////
// Operations on objects.
//////////////////////////////////////////////////////////////////////////
//! Makes object visible or invisible.
void HideObject(CBaseObject* obj, bool hide);
void HideObject(CBaseObject* obj, bool hide) override;
//! Shows the last hidden object based on hidden ID
void ShowLastHiddenObject();
void ShowLastHiddenObject() override;
//! Freeze object, making it unselectable.
void FreezeObject(CBaseObject* obj, bool freeze);
void FreezeObject(CBaseObject* obj, bool freeze) override;
//! Unhide all hidden objects.
void UnhideAll();
void UnhideAll() override;
//! Unfreeze all frozen objects.
void UnfreezeAll();
void UnfreezeAll() override;
//////////////////////////////////////////////////////////////////////////
// Object Selection.
//////////////////////////////////////////////////////////////////////////
bool SelectObject(CBaseObject* obj, bool bUseMask = true);
void UnselectObject(CBaseObject* obj);
bool SelectObject(CBaseObject* obj, bool bUseMask = true) override;
void UnselectObject(CBaseObject* obj) override;
//! Select objects within specified distance from given position.
//! Return number of selected objects.
int SelectObjects(const AABB& box, bool bUnselect = false);
int SelectObjects(const AABB& box, bool bUnselect = false) override;
virtual void SelectEntities(std::set<CEntityObject*>& s);
void SelectEntities(std::set<CEntityObject*>& s) override;
int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false);
int MoveObjects(const AABB& box, const Vec3& offset, ImageRotationDegrees rotation, bool bIsCopy = false) override;
//! Selects/Unselects all objects within 2d rectangle in given viewport.
void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect);
void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids);
void SelectObjectsInRect(CViewport* view, const QRect& rect, bool bSelect) override;
void FindObjectsInRect(CViewport* view, const QRect& rect, std::vector<GUID>& guids) override;
//! Clear default selection set.
//! @Return number of objects removed from selection.
int ClearSelection();
int ClearSelection() override;
//! Deselect all current selected objects and selects object that were unselected.
//! @Return number of selected objects.
int InvertSelection();
int InvertSelection() override;
//! Get current selection.
CSelectionGroup* GetSelection() const { return m_currSelection; };
CSelectionGroup* GetSelection() const override { return m_currSelection; };
//! Get named selection.
CSelectionGroup* GetSelection(const QString& name) const;
CSelectionGroup* GetSelection(const QString& name) const override;
// Get selection group names
void GetNameSelectionStrings(QStringList& names);
void GetNameSelectionStrings(QStringList& names) override;
//! Change name of current selection group.
//! And store it in list.
void NameSelection(const QString& name);
void NameSelection(const QString& name) override;
//! Set one of name selections as current selection.
void SetSelection(const QString& name);
void RemoveSelection(const QString& name);
void SetSelection(const QString& name) override;
void RemoveSelection(const QString& name) override;
bool IsObjectDeletionAllowed(CBaseObject* pObject);
//! Delete all objects in selection group.
void DeleteSelection();
void DeleteSelection() override;
uint32 ForceID() const{return m_ForceID; }
void ForceID(uint32 FID){m_ForceID = FID; }
uint32 ForceID() const override{return m_ForceID; }
void ForceID(uint32 FID) override{m_ForceID = FID; }
//! Generates uniq name base on type name of object.
QString GenerateUniqueObjectName(const QString& typeName);
QString GenerateUniqueObjectName(const QString& typeName) override;
//! Register object name in object manager, needed for generating uniq names.
void RegisterObjectName(const QString& name);
void RegisterObjectName(const QString& name) override;
//! Decrease name number and remove if it was last in object manager, needed for generating uniq names.
void UpdateRegisterObjectName(const QString& name);
//! Enable/Disable generating of unique object names (Enabled by default).
//! Return previous value.
bool EnableUniqObjectNames(bool bEnable);
bool EnableUniqObjectNames(bool bEnable) override;
//! Register XML template of runtime class.
void RegisterClassTemplate(const XmlNodeRef& templ);
@@ -249,25 +249,25 @@ public:
void RegisterCVars();
//! Find object class by name.
CObjectClassDesc* FindClass(const QString& className);
void GetClassCategories(QStringList& categories);
CObjectClassDesc* FindClass(const QString& className) override;
void GetClassCategories(QStringList& categories) override;
void GetClassCategoryToolClassNamePairs(std::vector< std::pair<QString, QString> >& categoryToolClassNamePairs) override;
void GetClassTypes(const QString& category, QStringList& types);
void GetClassTypes(const QString& category, QStringList& types) override;
//! Export objects to xml.
//! When onlyShared is true ony objects with shared flags exported, overwise only not shared object exported.
void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared);
void ExportEntities(XmlNodeRef& rootNode);
void Export(const QString& levelPath, XmlNodeRef& rootNode, bool onlyShared) override;
void ExportEntities(XmlNodeRef& rootNode) override;
//! Serialize Objects in manager to specified XML Node.
//! @param flags Can be one of SerializeFlags.
void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL);
void Serialize(XmlNodeRef& rootNode, bool bLoading, int flags = SERIALIZE_ALL) override;
void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading);
void SerializeNameSelection(XmlNodeRef& rootNode, bool bLoading) override;
//! Load objects from object archive.
//! @param bSelect if set newly loaded object will be selected.
void LoadObjects(CObjectArchive& ar, bool bSelect);
void LoadObjects(CObjectArchive& ar, bool bSelect) override;
//! Delete from Object manager all objects without SHARED flag.
void DeleteNotSharedObjects();
@@ -276,57 +276,57 @@ public:
bool AddObject(CBaseObject* obj);
void RemoveObject(CBaseObject* obj);
void ChangeObjectId(REFGUID oldId, REFGUID newId);
bool IsDuplicateObjectName(const QString& newName) const
void ChangeObjectId(REFGUID oldId, REFGUID newId) override;
bool IsDuplicateObjectName(const QString& newName) const override
{
return FindObject(newName) ? true : false;
}
void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const;
void ChangeObjectName(CBaseObject* obj, const QString& newName);
void ShowDuplicationMsgWarning(CBaseObject* obj, const QString& newName, bool bShowMsgBox) const override;
void ChangeObjectName(CBaseObject* obj, const QString& newName) override;
//! Convert object of one type to object of another type.
//! Original object is deleted.
bool ConvertToType(CBaseObject* pObject, const QString& typeName);
bool ConvertToType(CBaseObject* pObject, const QString& typeName) override;
//! Set new selection callback.
//! @return previous selection callback.
IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback);
IObjectSelectCallback* SetSelectCallback(IObjectSelectCallback* callback) override;
// Enables/Disables creating of game objects.
void SetCreateGameObject(bool enable) { m_createGameObjects = enable; };
void SetCreateGameObject(bool enable) override { m_createGameObjects = enable; };
//! Return true if objects loaded from xml should immidiatly create game objects associated with them.
bool IsCreateGameObjects() const { return m_createGameObjects; };
bool IsCreateGameObjects() const override { return m_createGameObjects; };
//////////////////////////////////////////////////////////////////////////
//! Get access to gizmo manager.
IGizmoManager* GetGizmoManager();
IGizmoManager* GetGizmoManager() override;
//////////////////////////////////////////////////////////////////////////
//! Invalidate visibily settings of objects.
void InvalidateVisibleList();
void InvalidateVisibleList() override;
//////////////////////////////////////////////////////////////////////////
// ObjectManager notification Callbacks.
//////////////////////////////////////////////////////////////////////////
void AddObjectEventListener(EventListener* listener);
void RemoveObjectEventListener(EventListener* listener);
void AddObjectEventListener(EventListener* listener) override;
void RemoveObjectEventListener(EventListener* listener) override;
//////////////////////////////////////////////////////////////////////////
// Used to indicate starting and ending of objects loading.
//////////////////////////////////////////////////////////////////////////
void StartObjectsLoading(int numObjects);
void EndObjectsLoading();
void StartObjectsLoading(int numObjects) override;
void EndObjectsLoading() override;
//////////////////////////////////////////////////////////////////////////
// Gathers all resources used by all objects.
void GatherUsedResources(CUsedResources& resources);
void GatherUsedResources(CUsedResources& resources) override;
virtual bool IsLightClass(CBaseObject* pObject);
bool IsLightClass(CBaseObject* pObject) override;
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue);
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue);
virtual void FindAndRenameProperty2(const char* property2Name, const QString& oldValue, const QString& newValue) override;
virtual void FindAndRenameProperty2If(const char* property2Name, const QString& oldValue, const QString& newValue, const char* otherProperty2Name, const QString& otherValue) override;
bool IsReloading() const { return m_bInReloading; }
bool IsReloading() const override { return m_bInReloading; }
void SetSkipUpdate(bool bSkipUpdate) override { m_bSkipObjectUpdate = bSkipUpdate; }
void SetExportingLevel(bool bExporting) override { m_bLevelExporting = bExporting; }
@@ -341,7 +341,7 @@ private:
@param objectNode Xml node to serialize object info from.
@param pUndoObject Pointer to deleted object for undo.
*/
CBaseObject* NewObject(CObjectArchive& archive, CBaseObject* pUndoObject, bool bMakeNewId);
CBaseObject* NewObject(CObjectArchive& archive, CBaseObject* pUndoObject, bool bMakeNewId) override;
//! Update visibility of all objects.
void UpdateVisibilityList();