1
0
forked from 0ad/0ad

add the ability to exclude props from the selection size + add aura visualisation rings again

This was SVN commit r14497.
This commit is contained in:
sanderd17 2014-01-04 10:41:32 +00:00
parent 4b1297b328
commit d4b2c1285c
7 changed files with 22 additions and 14 deletions

View File

@ -8,6 +8,7 @@
<prop actor="props/structures/athenians/temple_decor.xml" attachpoint="root"/>
<prop actor="props/structures/athenians/temple_props_a.xml" attachpoint="root"/>
<prop actor="props/structures/athenians/temple_tile_c.xml" attachpoint="root"/>
<prop actor="props/special/common/aura_60_green_rays.xml" attachpoint="root"/>
</props>
<textures>
<texture file="structural/hele_struct.dds" name="baseTex"/>

View File

@ -23,6 +23,7 @@
<prop actor="props/units/weapons/spear_lance.xml" attachpoint="r_hand"/>
<prop actor="props/units/shields/athen_aspis_pericles.xml" attachpoint="shield"/>
<prop actor="props/units/cape_hd.xml" attachpoint="shoulders"/>
<prop actor="props/special/common/aura_60_common.xml" attachpoint="root" selectable="false"/>
</props>
<textures><texture file="skeletal/hele_isp_e_f.dds" name="baseTex"/></textures>
</variant>

View File

@ -208,7 +208,7 @@ const CBoundingBoxAligned CModel::GetObjectSelectionBoundsRec()
for (size_t i = 0; i < m_Props.size(); ++i)
{
const Prop& prop = m_Props[i];
if (prop.m_Hidden)
if (prop.m_Hidden || !prop.m_Selectable)
continue; // prop is hidden from rendering, so it also shouldn't be used for selection
CBoundingBoxAligned propSelectionBounds = prop.m_Model->GetObjectSelectionBoundsRec();
@ -400,7 +400,7 @@ void CModel::ValidatePosition()
}
// Adjust prop height to terrain level when needed
if (prop.m_maxHeight != 0.f || prop.m_minHeight != 0.f)
if (prop.m_MaxHeight != 0.f || prop.m_MinHeight != 0.f)
{
CVector3D propTranslation = proptransform.GetTranslation();
CVector3D objTranslation = m_Transform.GetTranslation();
@ -410,8 +410,8 @@ void CModel::ValidatePosition()
{
float objTerrain = cmpTerrain->GetExactGroundLevel(objTranslation.X, objTranslation.Z);
float propTerrain = cmpTerrain->GetExactGroundLevel(propTranslation.X, propTranslation.Z);
float translateHeight = std::min(prop.m_maxHeight,
std::max(prop.m_minHeight, propTerrain - objTerrain));
float translateHeight = std::min(prop.m_MaxHeight,
std::max(prop.m_MinHeight, propTerrain - objTerrain));
CMatrix3D translate = CMatrix3D();
translate.SetTranslation(0.f, translateHeight, 0.f);
proptransform.Concatenate(translate);
@ -508,7 +508,7 @@ void CModel::CopyAnimationFrom(CModel* source)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AddProp: add a prop to the model on the given point
void CModel::AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight, float maxHeight)
void CModel::AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight, float maxHeight, bool selectable)
{
// position model according to prop point position
@ -520,8 +520,9 @@ void CModel::AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntr
prop.m_Point = point;
prop.m_Model = model;
prop.m_ObjectEntry = objectentry;
prop.m_minHeight = minHeight;
prop.m_maxHeight = maxHeight;
prop.m_MinHeight = minHeight;
prop.m_MaxHeight = maxHeight;
prop.m_Selectable = selectable;
m_Props.push_back(prop);
}
@ -603,7 +604,7 @@ CModelAbstract* CModel::Clone() const
if (m_AmmoPropPoint && i == m_AmmoLoadedProp)
clone->AddAmmoProp(m_Props[i].m_Point, m_Props[i].m_Model->Clone(), m_Props[i].m_ObjectEntry);
else
clone->AddProp(m_Props[i].m_Point, m_Props[i].m_Model->Clone(), m_Props[i].m_ObjectEntry, m_Props[i].m_minHeight, m_Props[i].m_maxHeight);
clone->AddProp(m_Props[i].m_Point, m_Props[i].m_Model->Clone(), m_Props[i].m_ObjectEntry, m_Props[i].m_MinHeight, m_Props[i].m_MaxHeight, m_Props[i].m_Selectable);
}
return clone;

View File

@ -54,10 +54,10 @@ class CModel : public CModelAbstract
public:
struct Prop
{
Prop() : m_minHeight(0.f), m_maxHeight(0.f), m_Point(0), m_Model(0), m_ObjectEntry(0), m_Hidden(false) {}
Prop() : m_MinHeight(0.f), m_MaxHeight(0.f), m_Point(0), m_Model(0), m_ObjectEntry(0), m_Hidden(false), m_Selectable(true) {}
float m_minHeight;
float m_maxHeight;
float m_MinHeight;
float m_MaxHeight;
/**
* Location of the prop point within its parent model, relative to either a bone in the parent model or to the
@ -75,6 +75,7 @@ public:
CObjectEntry* m_ObjectEntry;
bool m_Hidden; ///< Should this prop be temporarily removed from rendering?
bool m_Selectable; /// < should this prop count in the selection size?
};
public:
@ -213,7 +214,7 @@ public:
/**
* Add a prop to the model on the given point.
*/
void AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f);
void AddProp(const SPropPoint* point, CModelAbstract* model, CObjectEntry* objectentry, float minHeight = 0.f, float maxHeight = 0.f, bool selectable = true);
/**
* Add a prop to the model on the given point, and treat it as the ammo prop.

View File

@ -82,6 +82,7 @@ bool CObjectBase::Load(const VfsPath& pathname)
AT(offsetz);
AT(minheight);
AT(maxheight);
AT(selectable);
#undef AT
#undef EL
@ -252,6 +253,8 @@ bool CObjectBase::Load(const VfsPath& pathname)
prop.m_minHeight = pe.Value.ToFloat();
else if (pe.Name == at_maxheight)
prop.m_maxHeight = pe.Value.ToFloat();
else if (pe.Name == at_selectable)
prop.m_selectable = pe.Value != "false";
}
currentVariant->m_Props.push_back(prop);
}

View File

@ -56,7 +56,7 @@ public:
struct Prop
{
// constructor
Prop() : m_minHeight(0.f), m_maxHeight(0.f) {}
Prop() : m_minHeight(0.f), m_maxHeight(0.f), m_selectable(true) {}
// name of the prop point to attach to - "Prop01", "Prop02", "Head", "LeftHand", etc ..
CStr m_PropPointName;
// name of the model file - art/actors/props/sword.xml or whatever
@ -64,6 +64,7 @@ public:
// allow the prop to ajust the height from minHeight to maxHeight relative to the main model
float m_minHeight;
float m_maxHeight;
bool m_selectable;
};
struct Samp

View File

@ -235,7 +235,7 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
if (isAmmo)
model->AddAmmoProp(proppoint, propmodel, oe);
else
model->AddProp(proppoint, propmodel, oe, prop.m_minHeight, prop.m_maxHeight);
model->AddProp(proppoint, propmodel, oe, prop.m_minHeight, prop.m_maxHeight, prop.m_selectable);
if (propmodel->ToCModel())
propmodel->ToCModel()->SetAnimation(oe->GetRandomAnimation("idle"));
}