Integrating latest 47acbe8
This commit is contained in:
@@ -43,7 +43,7 @@ CAxisGizmo::CAxisGizmo(CBaseObject* object)
|
||||
SetFlags(EGIZMO_SELECTABLE | EGIZMO_TRANSFORM_MANIPULATOR);
|
||||
|
||||
m_axisGizmoCount++;
|
||||
m_object->AddEventListener(functor(*this, &CAxisGizmo::OnObjectEvent));
|
||||
m_object->AddEventListener(this);
|
||||
|
||||
m_localTM.SetIdentity();
|
||||
m_parentTM.SetIdentity();
|
||||
@@ -72,7 +72,7 @@ CAxisGizmo::~CAxisGizmo()
|
||||
{
|
||||
if (m_object)
|
||||
{
|
||||
m_object->RemoveEventListener(functor(*this, &CAxisGizmo::OnObjectEvent));
|
||||
m_object->RemoveEventListener(this);
|
||||
}
|
||||
m_axisGizmoCount--;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class CAxisHelperExtended;
|
||||
class SANDBOX_API CAxisGizmo
|
||||
: public CGizmo
|
||||
, public ITransformManipulator
|
||||
, public CBaseObject::EventListener
|
||||
{
|
||||
public:
|
||||
CAxisGizmo();
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
CBaseObjectPtr GetBaseObject() const override { return m_object; }
|
||||
|
||||
private:
|
||||
void OnObjectEvent(CBaseObject* object, int event);
|
||||
void OnObjectEvent(CBaseObject* object, int event) override;
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CBaseObjectPtr m_object;
|
||||
|
||||
@@ -1845,8 +1845,8 @@ void CBaseObject::Serialize(CObjectArchive& ar)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SetMaterial(mtlName);
|
||||
|
||||
ar.SetResolveCallback(this, parentId, functor(*this, &CBaseObject::ResolveParent));
|
||||
ar.SetResolveCallback(this, lookatId, functor(*this, &CBaseObject::SetLookAt));
|
||||
ar.SetResolveCallback(this, parentId, AZStd::bind(&CBaseObject::ResolveParent, this, AZStd::placeholders::_1 ));
|
||||
ar.SetResolveCallback(this, lookatId, AZStd::bind(&CBaseObject::SetLookAt, this, AZStd::placeholders::_1));
|
||||
|
||||
InvalidateTM(0);
|
||||
SetModified(false);
|
||||
@@ -2883,26 +2883,26 @@ bool CBaseObject::IsLookAtTarget() const
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::AddEventListener(const EventCallback& cb)
|
||||
void CBaseObject::AddEventListener(EventListener* listener)
|
||||
{
|
||||
if (find(m_eventListeners.begin(), m_eventListeners.end(), cb) == m_eventListeners.end())
|
||||
if (find(m_eventListeners.begin(), m_eventListeners.end(), listener) == m_eventListeners.end())
|
||||
{
|
||||
m_eventListeners.push_back(cb);
|
||||
m_eventListeners.push_back(listener);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::RemoveEventListener(const EventCallback& cb)
|
||||
void CBaseObject::RemoveEventListener(EventListener* listener)
|
||||
{
|
||||
std::vector<EventCallback>::iterator cbFound = find(m_eventListeners.begin(), m_eventListeners.end(), cb);
|
||||
if (cbFound != m_eventListeners.end())
|
||||
std::vector<EventListener*>::iterator listenerFound = find(m_eventListeners.begin(), m_eventListeners.end(), listener);
|
||||
if (listenerFound != m_eventListeners.end())
|
||||
{
|
||||
(*cbFound) = EventCallback();
|
||||
(*listenerFound) = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsBaseObjectEventCallbackNULL(const CBaseObject::EventCallback& cb) { return cb.getFunc() == NULL; }
|
||||
bool IsBaseObjectEventCallbackNULL(CBaseObject::EventListener* listener) { return listener == nullptr; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CBaseObject::NotifyListeners(EObjectListenerEvent event)
|
||||
@@ -2910,15 +2910,14 @@ void CBaseObject::NotifyListeners(EObjectListenerEvent event)
|
||||
for (auto it = m_eventListeners.begin(); it != m_eventListeners.end(); ++it)
|
||||
{
|
||||
// Call listener callback.
|
||||
if ((*it).getFunc() != NULL)
|
||||
if (*it)
|
||||
{
|
||||
(*it)(this, event);
|
||||
(*it)->OnObjectEvent(this, event);
|
||||
}
|
||||
}
|
||||
|
||||
m_eventListeners.erase(remove_if(m_eventListeners.begin(), m_eventListeners.end(), IsBaseObjectEventCallbackNULL), std::end(m_eventListeners));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CBaseObject::ConvertFromObject(CBaseObject* object)
|
||||
{
|
||||
@@ -3169,9 +3168,6 @@ void CBaseObject::OnContextMenu(QMenu* menu)
|
||||
GatherUsedResources(resources);
|
||||
|
||||
static_cast<CEditorImpl*>(GetIEditor())->OnObjectContextMenuOpened(menu, this);
|
||||
|
||||
//TODO: to be re-added when AssetBrowser is loading fast
|
||||
//menu->Add("Show in Asset Browser", functor(*this, &CBaseObject::OnMenuShowInAssetBrowser)).Enable(!resources.files.empty());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -236,7 +236,7 @@ class SANDBOX_API CBaseObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! Events sent by object to listeners in EventCallback.
|
||||
//! Events sent by object to EventListeners
|
||||
enum EObjectListenerEvent
|
||||
{
|
||||
ON_DELETE = 0,// Sent after object was deleted from object manager.
|
||||
@@ -260,7 +260,10 @@ public:
|
||||
};
|
||||
|
||||
//! This callback will be called if object is deleted.
|
||||
typedef Functor2<CBaseObject*, int> EventCallback;
|
||||
struct EventListener
|
||||
{
|
||||
virtual void OnObjectEvent(CBaseObject*, int) = 0;
|
||||
};
|
||||
|
||||
//! Childs structure.
|
||||
typedef std::vector<_smart_ptr<CBaseObject> > Childs;
|
||||
@@ -547,9 +550,9 @@ public:
|
||||
void StoreUndo(const char* undoDescription, bool minimal = false, int flags = 0);
|
||||
|
||||
//! Add event listener callback.
|
||||
void AddEventListener(const EventCallback& cb);
|
||||
void AddEventListener(EventListener* listener);
|
||||
//! Remove event listener callback.
|
||||
void RemoveEventListener(const EventCallback& cb);
|
||||
void RemoveEventListener(EventListener* listener);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Material handling for this base object.
|
||||
@@ -868,7 +871,7 @@ private:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Listeners.
|
||||
std::vector<EventCallback> m_eventListeners;
|
||||
std::vector<EventListener*> m_eventListeners;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Flags and bit masks.
|
||||
|
||||
@@ -40,7 +40,7 @@ DisplayContext::DisplayContext()
|
||||
|
||||
m_currentMatrix = 0;
|
||||
m_matrixStack[m_currentMatrix].SetIdentity();
|
||||
pRenderAuxGeom = gEnv->pRenderer->GetIRenderAuxGeom();
|
||||
pRenderAuxGeom = gEnv->pRenderer ? gEnv->pRenderer->GetIRenderAuxGeom() : nullptr;
|
||||
m_thickness = 0;
|
||||
|
||||
m_width = 0;
|
||||
|
||||
@@ -238,6 +238,27 @@ CEntityObject::CEntityObject()
|
||||
m_physicsState = 0;
|
||||
|
||||
m_attachmentType = eAT_Pivot;
|
||||
|
||||
// cache all the variable callbacks, must match order of enum defined in header
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaHeightChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaLightChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaLightSizeChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnAreaWidthChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxHeightChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxLengthChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxProjectionChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeXChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeYChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxSizeZChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnBoxWidthChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnColorChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnInnerRadiusChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnOuterRadiusChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectInAllDirsChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectorFOVChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnProjectorTextureChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnPropertyChange, this, AZStd::placeholders::_1));
|
||||
m_onSetCallbacksCache.push_back(AZStd::bind(&CEntityObject::OnRadiusChange, this, AZStd::placeholders::_1));
|
||||
}
|
||||
|
||||
CEntityObject::~CEntityObject()
|
||||
@@ -930,7 +951,8 @@ void CEntityObject::Serialize(CObjectArchive& ar)
|
||||
m_eventTargets.push_back(et);
|
||||
if (targetId != GUID_NULL)
|
||||
{
|
||||
ar.SetResolveCallback(this, targetId, functor(*this, &CEntityObject::ResolveEventTarget), i);
|
||||
using namespace AZStd::placeholders;
|
||||
ar.SetResolveCallback(this, targetId, AZStd::bind(&CEntityObject::ResolveEventTarget, this, _1, _2), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1410,7 +1432,7 @@ void CEntityObject::ResolveEventTarget(CBaseObject* object, unsigned int index)
|
||||
assert(index >= 0 && index < m_eventTargets.size());
|
||||
if (object)
|
||||
{
|
||||
object->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
|
||||
object->AddEventListener(this);
|
||||
}
|
||||
m_eventTargets[index].target = object;
|
||||
|
||||
@@ -1522,7 +1544,7 @@ void CEntityObject::SaveLink(XmlNodeRef xmlNode)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::OnEventTargetEvent(CBaseObject* target, int event)
|
||||
void CEntityObject::OnObjectEvent(CBaseObject* target, int event)
|
||||
{
|
||||
// When event target is deleted.
|
||||
if (event == CBaseObject::ON_DELETE)
|
||||
@@ -1566,7 +1588,7 @@ int CEntityObject::AddEventTarget(CBaseObject* target, const QString& event, con
|
||||
// Assign event target.
|
||||
if (et.target)
|
||||
{
|
||||
et.target->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
|
||||
et.target->AddEventListener(this);
|
||||
}
|
||||
|
||||
if (target)
|
||||
@@ -1600,7 +1622,7 @@ void CEntityObject::RemoveEventTarget(int index, [[maybe_unused]] bool bUpdateSc
|
||||
|
||||
if (m_eventTargets[index].target)
|
||||
{
|
||||
m_eventTargets[index].target->RemoveEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
|
||||
m_eventTargets[index].target->RemoveEventListener(this);
|
||||
}
|
||||
m_eventTargets.erase(m_eventTargets.begin() + index);
|
||||
|
||||
@@ -1634,7 +1656,7 @@ int CEntityObject::AddEntityLink(const QString& name, GUID targetEntityId)
|
||||
// Assign event target.
|
||||
if (target)
|
||||
{
|
||||
target->AddEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
|
||||
target->AddEventListener(this);
|
||||
|
||||
// Make line gizmo.
|
||||
pLineGizmo = new CLineGizmo;
|
||||
@@ -1684,7 +1706,7 @@ void CEntityObject::RemoveEntityLink(int index)
|
||||
|
||||
if (link.target)
|
||||
{
|
||||
link.target->RemoveEventListener(functor(*this, &CEntityObject::OnEventTargetEvent));
|
||||
link.target->RemoveEventListener(this);
|
||||
link.target->EntityUnlinked(link.name, GetId());
|
||||
}
|
||||
m_links.erase(m_links.begin() + index);
|
||||
@@ -2188,7 +2210,7 @@ void CEntityObject::ResetCallbacks()
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_proximityRadius);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnRadiusChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnRadiusChange]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2196,7 +2218,7 @@ void CEntityObject::ResetCallbacks()
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_proximityRadius);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnRadiusChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnRadiusChange]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2204,39 +2226,39 @@ void CEntityObject::ResetCallbacks()
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_innerRadius);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnInnerRadiusChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnInnerRadiusChange]);
|
||||
}
|
||||
var = pProperties->FindVariable("OuterRadius", false);
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_outerRadius);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnOuterRadiusChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnOuterRadiusChange]);
|
||||
}
|
||||
|
||||
var = pProperties->FindVariable("BoxSizeX", false);
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_boxSizeX);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeXChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeXChange]);
|
||||
}
|
||||
var = pProperties->FindVariable("BoxSizeY", false);
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_boxSizeY);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeYChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeYChange]);
|
||||
}
|
||||
var = pProperties->FindVariable("BoxSizeZ", false);
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_boxSizeZ);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxSizeZChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxSizeZChange]);
|
||||
}
|
||||
|
||||
var = pProperties->FindVariable("fAttenuationBulbSize");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fAreaLightSize);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaLightSizeChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaLightSizeChange]);
|
||||
}
|
||||
|
||||
IVariable* pProjector = pProperties->FindVariable("Projector");
|
||||
@@ -2246,7 +2268,7 @@ void CEntityObject::ResetCallbacks()
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_projectorFOV);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectorFOVChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectorFOVChange]);
|
||||
}
|
||||
var = pProjector->FindVariable("bProjectInAllDirs");
|
||||
if (var && var->GetType() == IVariable::BOOL)
|
||||
@@ -2254,7 +2276,7 @@ void CEntityObject::ResetCallbacks()
|
||||
int value;
|
||||
var->Get(value);
|
||||
m_bProjectInAllDirs = value;
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectInAllDirsChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectInAllDirsChange]);
|
||||
}
|
||||
var = pProjector->FindVariable("texture_Texture");
|
||||
if (var && var->GetType() == IVariable::STRING)
|
||||
@@ -2262,7 +2284,7 @@ void CEntityObject::ResetCallbacks()
|
||||
QString projectorTexture;
|
||||
var->Get(projectorTexture);
|
||||
m_bProjectorHasTexture = !projectorTexture.isEmpty();
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnProjectorTextureChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnProjectorTextureChange]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2282,7 +2304,7 @@ void CEntityObject::ResetCallbacks()
|
||||
if (name == "clrDiffuse")
|
||||
{
|
||||
pChild->Get(m_lightColor);
|
||||
SetVariableCallback(pChild, functor(*this, &CEntityObject::OnColorChange));
|
||||
SetVariableCallback(pChild, &m_onSetCallbacksCache[VariableCallbackIndex::OnColorChange]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2297,19 +2319,19 @@ void CEntityObject::ResetCallbacks()
|
||||
int value;
|
||||
var->Get(value);
|
||||
m_bAreaLight = value;
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaLightChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaLightChange]);
|
||||
}
|
||||
var = pType->FindVariable("fPlaneWidth");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fAreaWidth);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaWidthChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaWidthChange]);
|
||||
}
|
||||
var = pType->FindVariable("fPlaneHeight");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fAreaHeight);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnAreaHeightChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnAreaHeightChange]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2322,40 +2344,40 @@ void CEntityObject::ResetCallbacks()
|
||||
int value;
|
||||
var->Get(value);
|
||||
m_bBoxProjectedCM = value;
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxProjectionChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxProjectionChange]);
|
||||
}
|
||||
var = pProjection->FindVariable("fBoxWidth");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fBoxWidth);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxWidthChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxWidthChange]);
|
||||
}
|
||||
var = pProjection->FindVariable("fBoxHeight");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fBoxHeight);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxHeightChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxHeightChange]);
|
||||
}
|
||||
var = pProjection->FindVariable("fBoxLength");
|
||||
if (var && (var->GetType() == IVariable::FLOAT || var->GetType() == IVariable::INT))
|
||||
{
|
||||
var->Get(m_fBoxLength);
|
||||
SetVariableCallback(var, functor(*this, &CEntityObject::OnBoxLengthChange));
|
||||
SetVariableCallback(var, &m_onSetCallbacksCache[VariableCallbackIndex::OnBoxLengthChange]);
|
||||
}
|
||||
}
|
||||
|
||||
// Each property must have callback to our OnPropertyChange.
|
||||
pProperties->AddOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
|
||||
pProperties->AddOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
|
||||
}
|
||||
|
||||
if (pProperties2)
|
||||
{
|
||||
pProperties2->AddOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
|
||||
pProperties2->AddOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CEntityObject::SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback func)
|
||||
void CEntityObject::SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback* func)
|
||||
{
|
||||
pVar->AddOnSetCallback(func);
|
||||
m_callbacks.push_back(std::make_pair(pVar, func));
|
||||
@@ -2366,12 +2388,12 @@ void CEntityObject::ClearCallbacks()
|
||||
{
|
||||
if (m_pProperties)
|
||||
{
|
||||
m_pProperties->RemoveOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
|
||||
m_pProperties->RemoveOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
|
||||
}
|
||||
|
||||
if (m_pProperties2)
|
||||
{
|
||||
m_pProperties2->RemoveOnSetCallback(functor(*this, &CEntityObject::OnPropertyChange));
|
||||
m_pProperties2->RemoveOnSetCallback(&m_onSetCallbacksCache[VariableCallbackIndex::OnPropertyChange]);
|
||||
}
|
||||
|
||||
for (auto iter = m_callbacks.begin(); iter != m_callbacks.end(); ++iter)
|
||||
|
||||
@@ -76,6 +76,7 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
*/
|
||||
class CRYEDIT_API CEntityObject
|
||||
: public CBaseObject
|
||||
, public CBaseObject::EventListener
|
||||
{
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
@@ -267,7 +268,7 @@ protected:
|
||||
void OnPropertyChange(IVariable* var);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual void OnEventTargetEvent(CBaseObject* target, int event);
|
||||
void OnObjectEvent(CBaseObject* target, int event) override;
|
||||
void ResolveEventTarget(CBaseObject* object, unsigned int index);
|
||||
void ReleaseEventTargets();
|
||||
|
||||
@@ -424,15 +425,45 @@ protected:
|
||||
QString m_attachmentTarget;
|
||||
|
||||
private:
|
||||
struct VariableCallbackIndex
|
||||
{
|
||||
enum : unsigned char
|
||||
{
|
||||
OnAreaHeightChange = 0,
|
||||
OnAreaLightChange,
|
||||
OnAreaLightSizeChange,
|
||||
OnAreaWidthChange,
|
||||
OnBoxHeightChange,
|
||||
OnBoxLengthChange,
|
||||
OnBoxProjectionChange,
|
||||
OnBoxSizeXChange,
|
||||
OnBoxSizeYChange,
|
||||
OnBoxSizeZChange,
|
||||
OnBoxWidthChange,
|
||||
OnColorChange,
|
||||
OnInnerRadiusChange,
|
||||
OnOuterRadiusChange,
|
||||
OnProjectInAllDirsChange,
|
||||
OnProjectorFOVChange,
|
||||
OnProjectorTextureChange,
|
||||
OnPropertyChange,
|
||||
OnRadiusChange,
|
||||
|
||||
// must be at the end
|
||||
Count,
|
||||
};
|
||||
};
|
||||
|
||||
void ResetCallbacks();
|
||||
void SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback func);
|
||||
void SetVariableCallback(IVariable* pVar, IVariable::OnSetCallback* func);
|
||||
void ClearCallbacks();
|
||||
|
||||
void ForceVariableUpdate();
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
CListenerSet<IEntityObjectListener*> m_listeners;
|
||||
std::vector< std::pair<IVariable*, IVariable::OnSetCallback> > m_callbacks;
|
||||
std::vector< std::pair<IVariable*, IVariable::OnSetCallback*> > m_callbacks;
|
||||
AZStd::fixed_vector< IVariable::OnSetCallback, VariableCallbackIndex::Count > m_onSetCallbacksCache;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ CLineGizmo::~CLineGizmo()
|
||||
{
|
||||
if (m_object[0])
|
||||
{
|
||||
m_object[0]->RemoveEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
|
||||
m_object[0]->RemoveEventListener(this);
|
||||
}
|
||||
if (m_object[1])
|
||||
{
|
||||
m_object[1]->RemoveEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
|
||||
m_object[1]->RemoveEventListener(this);
|
||||
}
|
||||
m_object[0] = 0;
|
||||
m_object[1] = 0;
|
||||
@@ -54,8 +54,8 @@ void CLineGizmo::SetObjects(CBaseObject* pObject1, CBaseObject* pObject2, const
|
||||
m_object[1] = pObject2;
|
||||
m_boneName = boneName;
|
||||
|
||||
m_object[0]->AddEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
|
||||
m_object[1]->AddEventListener(functor(*this, &CLineGizmo::OnObjectEvent));
|
||||
m_object[0]->AddEventListener(this);
|
||||
m_object[1]->AddEventListener(this);
|
||||
CalcBounds();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ struct DisplayContext;
|
||||
*/
|
||||
class CLineGizmo
|
||||
: public CGizmo
|
||||
, public CBaseObject::EventListener
|
||||
{
|
||||
public:
|
||||
CLineGizmo();
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
void SetColor(const Vec3& color1, const Vec3& color2, float alpha1 = 1.0f, float alpha2 = 1.0f);
|
||||
|
||||
private:
|
||||
void OnObjectEvent(CBaseObject* object, int event);
|
||||
void OnObjectEvent(CBaseObject* object, int event) override;
|
||||
void CalcBounds();
|
||||
|
||||
CBaseObjectPtr m_object[2];
|
||||
|
||||
@@ -44,9 +44,9 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
|
||||
~CObjectArchive();
|
||||
|
||||
//! Resolve callback with only one parameter of CBaseObject.
|
||||
typedef Functor1<CBaseObject*> ResolveObjRefFunctor1;
|
||||
typedef AZStd::function<void(CBaseObject*)> ResolveObjRefFunctor1;
|
||||
//! Resolve callback with two parameters one is pointer to CBaseObject and second use data integer.
|
||||
typedef Functor2<CBaseObject*, unsigned int> ResolveObjRefFunctor2;
|
||||
typedef AZStd::function<void(CBaseObject*, unsigned int)> ResolveObjRefFunctor2;
|
||||
|
||||
/** Register Object id.
|
||||
@param objectId Original object id from the file.
|
||||
|
||||
@@ -986,7 +986,7 @@ void CObjectManager::UnselectObject(CBaseObject* obj)
|
||||
{
|
||||
SetObjectSelected(obj, false);
|
||||
}
|
||||
|
||||
|
||||
m_currSelection->RemoveObject(obj);
|
||||
}
|
||||
|
||||
@@ -1141,7 +1141,7 @@ int CObjectManager::ClearSelection()
|
||||
GetIEditor()->RecordUndo(new CUndoBaseObjectClearSelection(*m_currSelection));
|
||||
}
|
||||
|
||||
// Handle legacy entities separately so the selection group can be cleared safely.
|
||||
// Handle legacy entities separately so the selection group can be cleared safely.
|
||||
// This prevents every AzEntity from being removed one by one from a vector.
|
||||
m_currSelection->RemoveAllExceptLegacySet();
|
||||
|
||||
@@ -1163,7 +1163,7 @@ int CObjectManager::ClearSelection()
|
||||
|
||||
// Unselect all component entities as one bulk operation instead of individually
|
||||
AzToolsFramework::ToolsApplicationRequestBus::Broadcast(
|
||||
&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities,
|
||||
&AzToolsFramework::ToolsApplicationRequests::SetSelectedEntities,
|
||||
AzToolsFramework::EntityIdList());
|
||||
|
||||
m_processingBulkSelect = false;
|
||||
@@ -1927,7 +1927,7 @@ void CObjectManager::SelectObjectsInRect(CViewport* view, const QRect& rect, boo
|
||||
CBaseObjectsCache* displayedViewObjects = view->GetVisibleObjectsCache();
|
||||
int numVis = displayedViewObjects->GetObjectCount();
|
||||
|
||||
// Tracking the previous selection allows proper undo/redo functionality of additional
|
||||
// Tracking the previous selection allows proper undo/redo functionality of additional
|
||||
// selections (CTRL + drag select)
|
||||
AZStd::unordered_set<const CBaseObject*> previousSelection;
|
||||
|
||||
@@ -1944,7 +1944,7 @@ void CObjectManager::SelectObjectsInRect(CViewport* view, const QRect& rect, boo
|
||||
// This will update m_currSelection
|
||||
SelectObjectInRect(object, view, hc, bSelect);
|
||||
|
||||
// Legacy undo/redo does not go through the Ebus system and must be done individually
|
||||
// Legacy undo/redo does not go through the Ebus system and must be done individually
|
||||
if (isUndoRecording && object->GetType() != OBJTYPE_AZENTITY)
|
||||
{
|
||||
GetIEditor()->RecordUndo(new CUndoBaseObjectSelect(object, true));
|
||||
@@ -2517,27 +2517,27 @@ void CObjectManager::HideTransformManipulators()
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectManager::AddObjectEventListener(const EventCallback& cb)
|
||||
void CObjectManager::AddObjectEventListener(EventListener* listener)
|
||||
{
|
||||
stl::push_back_unique(m_objectEventListeners, cb);
|
||||
stl::push_back_unique(m_objectEventListeners, listener);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectManager::RemoveObjectEventListener(const EventCallback& cb)
|
||||
void CObjectManager::RemoveObjectEventListener(EventListener* listener)
|
||||
{
|
||||
stl::find_and_erase(m_objectEventListeners, cb);
|
||||
stl::find_and_erase(m_objectEventListeners, listener);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CObjectManager::NotifyObjectListeners(CBaseObject* pObject, CBaseObject::EObjectListenerEvent event)
|
||||
{
|
||||
std::list<EventCallback>::iterator next;
|
||||
for (std::list<EventCallback>::iterator it = m_objectEventListeners.begin(); it != m_objectEventListeners.end(); it = next)
|
||||
std::list<EventListener*>::iterator next;
|
||||
for (std::list<EventListener*>::iterator it = m_objectEventListeners.begin(); it != m_objectEventListeners.end(); it = next)
|
||||
{
|
||||
next = it;
|
||||
++next;
|
||||
// Call listener callback.
|
||||
(*it)(pObject, event);
|
||||
(*it)->OnObjectEvent(pObject, event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3004,7 +3004,7 @@ namespace
|
||||
aabb.min.x,
|
||||
aabb.min.y,
|
||||
aabb.min.z
|
||||
),
|
||||
),
|
||||
AZ::Vector3(
|
||||
aabb.max.x,
|
||||
aabb.max.y,
|
||||
|
||||
@@ -315,8 +315,8 @@ public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ObjectManager notification Callbacks.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void AddObjectEventListener(const EventCallback& cb);
|
||||
void RemoveObjectEventListener(const EventCallback& cb);
|
||||
void AddObjectEventListener(EventListener* listener);
|
||||
void RemoveObjectEventListener(EventListener* listener);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Used to indicate starting and ending of objects loading.
|
||||
@@ -445,7 +445,7 @@ private:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Listeners.
|
||||
std::list<EventCallback> m_objectEventListeners;
|
||||
std::list<EventListener*> m_objectEventListeners;
|
||||
|
||||
bool m_bExiting;
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ CObjectPhysicsManager::CObjectPhysicsManager()
|
||||
{
|
||||
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
|
||||
"physics", "simulate_objects", "", "",
|
||||
functor(*this, &CObjectPhysicsManager::Command_SimulateObjects));
|
||||
AZStd::bind(&CObjectPhysicsManager::Command_SimulateObjects, this));
|
||||
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
|
||||
"physics", "reset_objects_state", "", "",
|
||||
functor(*this, &CObjectPhysicsManager::Command_ResetPhysicsState));
|
||||
AZStd::bind(&CObjectPhysicsManager::Command_ResetPhysicsState, this));
|
||||
CommandManagerHelper::RegisterCommand(GetIEditor()->GetCommandManager(),
|
||||
"physics", "get_objects_state", "", "",
|
||||
functor(*this, &CObjectPhysicsManager::Command_GetPhysicsState));
|
||||
AZStd::bind(&CObjectPhysicsManager::Command_GetPhysicsState, this));
|
||||
|
||||
m_fStartObjectSimulationTime = 0;
|
||||
m_bSimulatingObjects = false;
|
||||
|
||||
Reference in New Issue
Block a user