Getting rid of CylinderLarge, replacing with preview volume scaling support

This commit is contained in:
parax0
2015-12-16 17:44:21 -07:00
parent 2a38fb5b09
commit 6e3deb836c
11 changed files with 86 additions and 18 deletions

View File

@@ -39,6 +39,7 @@ void CScriptObject::EvaluateProperties()
mpLightParameters = mpTemplate->FindLightParameters(mpProperties);
mHasInGameModel = mpTemplate->HasInGameModel(mpProperties);
mVolumeShape = mpTemplate->VolumeShape(this);
mVolumeScale = mpTemplate->VolumeScale(this);
EvaluateDisplayModel();
EvaluateBillboard();
EvaluateCollisionModel();
@@ -224,3 +225,8 @@ EVolumeShape CScriptObject::VolumeShape() const
{
return mVolumeShape;
}
float CScriptObject::VolumeScale() const
{
return mVolumeScale;
}

View File

@@ -37,6 +37,7 @@ class CScriptObject
bool mHasInGameModel;
EVolumeShape mVolumeShape;
float mVolumeScale;
public:
CScriptObject(CGameArea *pArea, CScriptLayer *pLayer, CScriptTemplate *pTemplate);
@@ -79,6 +80,7 @@ public:
CTexture* GetBillboard() const;
CCollisionMeshGroup* GetCollision() const;
EVolumeShape VolumeShape() const;
float VolumeScale() const;
};
#endif // CSCRIPTOBJECT_H

View File

@@ -13,6 +13,7 @@ CScriptTemplate::CScriptTemplate(CMasterTemplate *pMaster)
mpMaster = pMaster;
mVisible = true;
mPreviewScale = 1.f;
mVolumeScale = 1.f;
mVolumeShape = eNoShape;
}
@@ -145,6 +146,35 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
return eInvalidShape;
}
if (mVolumeShape == eConditionalShape)
{
s32 index = CheckVolumeConditions(pObj, true);
if (index == -1) return eInvalidShape;
else return mVolumeConditions[index].Shape;
}
else return mVolumeShape;
}
float CScriptTemplate::VolumeScale(CScriptObject *pObj)
{
if (pObj->Template() != this)
{
Log::Error(pObj->Template()->TemplateName() + " instance somehow called VolumeScale() on " + TemplateName() + " template");
return -1;
}
if (mVolumeShape == eConditionalShape)
{
s32 index = CheckVolumeConditions(pObj, false);
if (index == -1) return mVolumeScale;
else return mVolumeConditions[index].Scale;
}
else return mVolumeScale;
}
s32 CScriptTemplate::CheckVolumeConditions(CScriptObject *pObj, bool LogErrors)
{
// Private function
if (mVolumeShape == eConditionalShape)
{
CPropertyBase *pProp = pObj->Properties()->PropertyByIDString(mVolumeConditionIDString);
@@ -179,17 +209,17 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
}
// Test and check whether any of the conditions are true
for (auto it = mVolumeConditions.begin(); it != mVolumeConditions.end(); it++)
for (u32 iCon = 0; iCon < mVolumeConditions.size(); iCon++)
{
if (it->Value == v)
return it->Shape;
if (mVolumeConditions[iCon].Value == v)
return iCon;
}
Log::Error(TemplateName() + " instance " + TString::HexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + TString::HexString((u32) v, true, true));
return eInvalidShape;
if (LogErrors)
Log::Error(pObj->Template()->TemplateName() + " instance " + TString::HexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + TString::HexString((u32) v, true, true));
}
else return mVolumeShape;
return -1;
}
CStringProperty* CScriptTemplate::FindInstanceName(CPropertyStruct *pProperties)

View File

@@ -81,11 +81,13 @@ private:
// Preview Volume
EVolumeShape mVolumeShape;
float mVolumeScale;
TIDString mVolumeConditionIDString;
struct SVolumeCondition {
int Value;
EVolumeShape Shape;
float Scale;
};
std::vector<SVolumeCondition> mVolumeConditions;
@@ -111,6 +113,7 @@ public:
CStructTemplate* BaseStructByCount(s32 propCount);
CStructTemplate* BaseStructByIndex(u32 index);
EVolumeShape VolumeShape(CScriptObject *pObj);
float VolumeScale(CScriptObject *pObj);
CStringProperty* FindInstanceName(CPropertyStruct *pProperties);
CVector3Property* FindPosition(CPropertyStruct *pProperties);
CVector3Property* FindRotation(CPropertyStruct *pProperties);
@@ -129,6 +132,9 @@ public:
void AddObject(CScriptObject *pObject);
void RemoveObject(CScriptObject *pObject);
void SortObjects();
private:
s32 CheckVolumeConditions(CScriptObject *pObj, bool LogErrors);
};
#endif // CSCRIPTTEMPLATE_H

View File

@@ -8,7 +8,6 @@ enum EVolumeShape
eBoxShape,
eEllipsoidShape,
eCylinderShape,
eCylinderLargeShape,
eConditionalShape,
eInvalidShape
};