mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-13 15:16:28 +00:00
Massive overhaul of property system done over the last few months. There is unfinished/broken stuff still, but it compiles now.
This commit is contained in:
@@ -10,8 +10,11 @@ CScriptAttachNode::CScriptAttachNode(CScene *pScene, const SAttachment& rkAttach
|
||||
, mAttachType(rkAttachment.AttachType)
|
||||
, mLocatorName(rkAttachment.LocatorName)
|
||||
{
|
||||
CPropertyStruct *pBaseStruct = pParent->Instance()->Properties();
|
||||
mpAttachAssetProp = pBaseStruct->PropertyByIDString(rkAttachment.AttachProperty);
|
||||
CStructPropertyNew* pBaseStruct = pParent->Template()->Properties();
|
||||
|
||||
mpAttachAssetProp = pBaseStruct->ChildByIDString(rkAttachment.AttachProperty);
|
||||
mAttachAssetRef = CAssetRef(pParent->Instance(), mpAttachAssetProp);
|
||||
mAttachAnimSetRef = CAnimationSetRef(pParent->Instance(), mpAttachAssetProp);
|
||||
if (mpAttachAssetProp) AttachPropertyModified();
|
||||
|
||||
ParentDisplayAssetChanged(mpScriptNode->DisplayAsset());
|
||||
@@ -21,12 +24,12 @@ void CScriptAttachNode::AttachPropertyModified()
|
||||
{
|
||||
if (mpAttachAssetProp)
|
||||
{
|
||||
if (mpAttachAssetProp->Type() == eAssetProperty)
|
||||
mpAttachAsset = gpResourceStore->LoadResource<CModel>( TPropCast<TAssetProperty>(mpAttachAssetProp)->Get() );
|
||||
else if (mpAttachAssetProp->Type() == eCharacterProperty)
|
||||
mpAttachAsset = TPropCast<TCharacterProperty>(mpAttachAssetProp)->Get().AnimSet();
|
||||
if (mAttachAssetRef.IsValid())
|
||||
mpAttachAsset = gpResourceStore->LoadResource<CModel>(mAttachAssetRef.Get());
|
||||
else if (mAttachAnimSetRef.IsValid())
|
||||
mpAttachAsset = mAttachAnimSetRef.Get().AnimSet();
|
||||
|
||||
CModel *pModel = Model();
|
||||
CModel* pModel = Model();
|
||||
|
||||
if (pModel && pModel->Type() == eModel)
|
||||
mLocalAABox = pModel->AABox();
|
||||
@@ -37,11 +40,11 @@ void CScriptAttachNode::AttachPropertyModified()
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptAttachNode::ParentDisplayAssetChanged(CResource *pNewDisplayAsset)
|
||||
void CScriptAttachNode::ParentDisplayAssetChanged(CResource* pNewDisplayAsset)
|
||||
{
|
||||
if (pNewDisplayAsset->Type() == eAnimSet)
|
||||
{
|
||||
CSkeleton *pSkel = mpScriptNode->ActiveSkeleton();
|
||||
CSkeleton* pSkel = mpScriptNode->ActiveSkeleton();
|
||||
mpLocator = pSkel->BoneByName(mLocatorName);
|
||||
}
|
||||
|
||||
@@ -60,11 +63,8 @@ CModel* CScriptAttachNode::Model() const
|
||||
if (mpAttachAsset->Type() == eModel)
|
||||
return static_cast<CModel*>(mpAttachAsset.RawPointer());
|
||||
|
||||
if (mpAttachAsset->Type() == eAnimSet)
|
||||
{
|
||||
TCharacterProperty *pProp = TPropCast<TCharacterProperty>(mpAttachAssetProp);
|
||||
return pProp->Get().GetCurrentModel();
|
||||
}
|
||||
else if (mpAttachAsset->Type() == eAnimSet)
|
||||
return mAttachAnimSetRef.Get().GetCurrentModel();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -2,20 +2,23 @@
|
||||
#define CSCRIPTATTACHNODE_H
|
||||
|
||||
#include "CSceneNode.h"
|
||||
#include "Core/Resource/Script/IProperty.h"
|
||||
#include "Core/Resource/Script/Property/Properties.h"
|
||||
#include "Core/Resource/Script/CScriptTemplate.h"
|
||||
|
||||
class CScriptNode;
|
||||
|
||||
class CScriptAttachNode : public CSceneNode
|
||||
{
|
||||
CScriptNode *mpScriptNode;
|
||||
CScriptNode* mpScriptNode;
|
||||
TResPtr<CResource> mpAttachAsset;
|
||||
IProperty *mpAttachAssetProp;
|
||||
|
||||
IPropertyNew* mpAttachAssetProp;
|
||||
CAssetRef mAttachAssetRef;
|
||||
CAnimationSetRef mAttachAnimSetRef;
|
||||
|
||||
EAttachType mAttachType;
|
||||
TString mLocatorName;
|
||||
CBone *mpLocator;
|
||||
CBone* mpLocator;
|
||||
|
||||
public:
|
||||
explicit CScriptAttachNode(CScene *pScene, const SAttachment& rkAttachment, CScriptNode *pParent);
|
||||
@@ -30,7 +33,7 @@ public:
|
||||
void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
|
||||
SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo);
|
||||
|
||||
inline IProperty* AttachProperty() const { return mpAttachAssetProp; }
|
||||
inline IPropertyNew* AttachProperty() const { return mpAttachAssetProp; }
|
||||
inline TString LocatorName() const { return mLocatorName; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -31,7 +31,7 @@ CScriptNode::CScriptNode(CScene *pScene, u32 NodeID, CSceneNode *pParent, CScrip
|
||||
CScriptTemplate *pTemp = Template();
|
||||
|
||||
// Determine transform
|
||||
mHasValidPosition = pTemp->HasPosition();
|
||||
mHasValidPosition = pTemp->PositionProperty() != nullptr;
|
||||
mPosition = mpInstance->Position();
|
||||
mRotation = CQuaternion::FromEuler(mpInstance->Rotation());
|
||||
mScale = mpInstance->Scale();
|
||||
@@ -99,15 +99,13 @@ void CScriptNode::OnTransformed()
|
||||
{
|
||||
if (mpInstance)
|
||||
{
|
||||
CScriptTemplate *pTemplate = Template();
|
||||
|
||||
if (pTemplate->HasPosition() && LocalPosition() != mpInstance->Position())
|
||||
if (LocalPosition() != mpInstance->Position())
|
||||
mpInstance->SetPosition(LocalPosition());
|
||||
|
||||
if (pTemplate->HasRotation() && LocalRotation().ToEuler() != mpInstance->Rotation())
|
||||
if (LocalRotation().ToEuler() != mpInstance->Rotation())
|
||||
mpInstance->SetRotation(LocalRotation().ToEuler());
|
||||
|
||||
if (pTemplate->HasScale() && LocalScale() != mpInstance->Scale())
|
||||
if (LocalScale() != mpInstance->Scale())
|
||||
mpInstance->SetScale(LocalScale());
|
||||
}
|
||||
|
||||
@@ -456,27 +454,29 @@ void CScriptNode::LinksModified()
|
||||
if (mpExtra) mpExtra->LinksModified();
|
||||
}
|
||||
|
||||
void CScriptNode::PropertyModified(IProperty *pProp)
|
||||
void CScriptNode::PropertyModified(IPropertyNew* pProp)
|
||||
{
|
||||
// Update volume
|
||||
if ( (pProp->Type() == eBoolProperty) || (pProp->Type() == eByteProperty) || (pProp->Type() == eShortProperty) ||
|
||||
(pProp->Type() == eLongProperty) || (pProp->Type() == eEnumProperty) )
|
||||
EPropertyTypeNew Type = pProp->Type();
|
||||
|
||||
if ( Type == EPropertyTypeNew::Bool || Type == EPropertyTypeNew::Byte || Type == EPropertyTypeNew::Short ||
|
||||
Type == EPropertyTypeNew::Int || Type == EPropertyTypeNew::Choice || Type == EPropertyTypeNew::Enum )
|
||||
{
|
||||
mpInstance->EvaluateVolume();
|
||||
UpdatePreviewVolume();
|
||||
}
|
||||
|
||||
// Update resources
|
||||
if (pProp->Type() == eCharacterProperty)
|
||||
else if (Type == EPropertyTypeNew::AnimationSet)
|
||||
{
|
||||
mpInstance->EvaluateDisplayAsset();
|
||||
SetDisplayAsset(mpInstance->DisplayAsset());
|
||||
}
|
||||
|
||||
else if (pProp->Type() == eAssetProperty)
|
||||
else if (Type == EPropertyTypeNew::Asset)
|
||||
{
|
||||
CAssetTemplate *pAssetTemp = static_cast<CAssetTemplate*>(pProp->Template());
|
||||
const CResTypeFilter& rkFilter = pAssetTemp->TypeFilter();
|
||||
CAssetProperty* pAssetProperty = TPropCast<CAssetProperty>(pProp);
|
||||
const CResTypeFilter& rkFilter = pAssetProperty->GetTypeFilter();
|
||||
|
||||
if (rkFilter.Accepts(eModel) || rkFilter.Accepts(eTexture) || rkFilter.Accepts(eAnimSet) || rkFilter.Accepts(eCharacter))
|
||||
{
|
||||
@@ -491,40 +491,37 @@ void CScriptNode::PropertyModified(IProperty *pProp)
|
||||
}
|
||||
|
||||
// Update other editor properties
|
||||
if (mpInstance->IsEditorProperty(pProp))
|
||||
{
|
||||
CScriptTemplate *pTemplate = Template();
|
||||
CScriptTemplate *pTemplate = Template();
|
||||
|
||||
if (pTemplate->HasName())
|
||||
SetName("[" + mpInstance->Template()->Name() + "] " + mpInstance->InstanceName());
|
||||
if (pProp == pTemplate->NameProperty())
|
||||
SetName("[" + mpInstance->Template()->Name() + "] " + mpInstance->InstanceName());
|
||||
|
||||
if (pTemplate->HasPosition())
|
||||
mPosition = mpInstance->Position();
|
||||
else if (pProp == pTemplate->PositionProperty())
|
||||
mPosition = mpInstance->Position();
|
||||
|
||||
if (pTemplate->HasRotation())
|
||||
mRotation = CQuaternion::FromEuler(mpInstance->Rotation());
|
||||
else if (pProp == pTemplate->RotationProperty())
|
||||
mRotation = CQuaternion::FromEuler(mpInstance->Rotation());
|
||||
|
||||
if (pTemplate->HasScale())
|
||||
mScale = mpInstance->Scale();
|
||||
else if (pProp == pTemplate->ScaleProperty())
|
||||
mScale = mpInstance->Scale();
|
||||
|
||||
MarkTransformChanged();
|
||||
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
||||
}
|
||||
MarkTransformChanged();
|
||||
SetLightLayerIndex(mpLightParameters->LightLayerIndex());
|
||||
|
||||
// Notify attachments
|
||||
for (u32 iAttach = 0; iAttach < mAttachments.size(); iAttach++)
|
||||
for (u32 AttachIdx = 0; AttachIdx < mAttachments.size(); AttachIdx++)
|
||||
{
|
||||
CScriptAttachNode *pAttach = mAttachments[iAttach];
|
||||
CScriptAttachNode* pAttachNode = mAttachments[AttachIdx];
|
||||
|
||||
if (pAttach->AttachProperty() == pProp)
|
||||
pAttach->AttachPropertyModified();
|
||||
if (pAttachNode->AttachProperty() == pProp)
|
||||
pAttachNode->AttachPropertyModified();
|
||||
}
|
||||
|
||||
// Notify script extra
|
||||
if (mpExtra) mpExtra->PropertyModified(pProp);
|
||||
|
||||
// Update game mode visibility
|
||||
if (pProp && pProp == mpInstance->ActiveProperty())
|
||||
if (pProp && pProp == pTemplate->ActiveProperty())
|
||||
TestGameModeVisibility();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
CColor WireframeColor() const;
|
||||
|
||||
void LinksModified();
|
||||
void PropertyModified(IProperty *pProp);
|
||||
void PropertyModified(IPropertyNew* pProp);
|
||||
void UpdatePreviewVolume();
|
||||
void GeneratePosition();
|
||||
void TestGameModeVisibility();
|
||||
|
||||
Reference in New Issue
Block a user