Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpPosition.cpp
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | return | ||||
"<value a:help='Rotate backwards and forwards to follow the terrain (e.g. animals)'>pitch</value>" | "<value a:help='Rotate backwards and forwards to follow the terrain (e.g. animals)'>pitch</value>" | ||||
"<value a:help='Rotate sideways to follow the terrain'>roll</value>" | "<value a:help='Rotate sideways to follow the terrain'>roll</value>" | ||||
"<value a:help='Rotate in all directions to follow the terrain (e.g. carts)'>pitch-roll</value>" | "<value a:help='Rotate in all directions to follow the terrain (e.g. carts)'>pitch-roll</value>" | ||||
"</choice>" | "</choice>" | ||||
"</element>" | "</element>" | ||||
"<element name='Altitude' a:help='Height above terrain in metres'>" | "<element name='Altitude' a:help='Height above terrain in metres'>" | ||||
"<data type='decimal'/>" | "<data type='decimal'/>" | ||||
"</element>" | "</element>" | ||||
"<element name='Floating' a:help='Whether the entity floats on water'>" | "<element name='Floating' a:help='Whether the entity floats on water'>" | ||||
elexis: Ambiguous definition.
It could mean "the entity is always in a state of floating on water"… | |||||
Not Done Inline ActionsAgreed. wraitii: Agreed.
The same applies to the m_Floating variable. | |||||
"<data type='boolean'/>" | "<data type='boolean'/>" | ||||
"</element>" | "</element>" | ||||
"<element name='FloatDepth' a:help='The depth at which an entity floats on water (needs Floating to be true)'>" | "<element name='FloatDepth' a:help='The depth at which an entity floats on water (needs Floating to be true)'>" | ||||
"<ref name='nonNegativeDecimal'/>" | "<ref name='nonNegativeDecimal'/>" | ||||
"</element>" | "</element>" | ||||
"<element name='TurnRate' a:help='Maximum graphical rotation speed around Y axis, in radians per second'>" | "<element name='TurnRate' a:help='Maximum graphical rotation speed around Y axis, in radians per second'>" | ||||
"<ref name='positiveDecimal'/>" | "<ref name='positiveDecimal'/>" | ||||
"</element>"; | "</element>"; | ||||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | public: | ||||
{ | { | ||||
// move y to use the right offset (from terrain or from map origin) | // move y to use the right offset (from terrain or from map origin) | ||||
m_Y = relative ? GetHeightOffset() : GetHeightFixed(); | m_Y = relative ? GetHeightOffset() : GetHeightFixed(); | ||||
m_RelativeToGround = relative; | m_RelativeToGround = relative; | ||||
m_LastYDifference = entity_pos_t::Zero(); | m_LastYDifference = entity_pos_t::Zero(); | ||||
AdvertiseInterpolatedPositionChanges(); | AdvertiseInterpolatedPositionChanges(); | ||||
} | } | ||||
virtual bool IsCurrentlyFloating() const | |||||
{ | |||||
if (!m_Floating) | |||||
return false; | |||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | |||||
CmpPtr<ICmpWaterManager> cmpWaterManager(GetSystemEntity()); | |||||
if (!cmpTerrain || !cmpWaterManager) | |||||
return false; | |||||
return cmpTerrain->GetGroundLevel(m_X, m_Z) < cmpWaterManager->GetWaterLevel(m_X, m_Z) - m_FloatDepth; | |||||
Not Done Inline ActionsI would go with a <= but no strong opinion. wraitii: I would go with a <= but no strong opinion. | |||||
} | |||||
virtual bool CanFloat() const | virtual bool CanFloat() const | ||||
{ | { | ||||
return m_Floating; | return m_Floating; | ||||
} | } | ||||
virtual void SetFloating(bool flag) | virtual void SetFloating(bool flag) | ||||
{ | { | ||||
m_Floating = flag; | m_Floating = flag; | ||||
▲ Show 20 Lines • Show All 459 Lines • ▼ Show 20 Lines | private: | ||||
void UpdateXZRotation() | void UpdateXZRotation() | ||||
{ | { | ||||
if (!m_InWorld) | if (!m_InWorld) | ||||
{ | { | ||||
LOGERROR("CCmpPosition::UpdateXZRotation called on entity when IsInWorld is false"); | LOGERROR("CCmpPosition::UpdateXZRotation called on entity when IsInWorld is false"); | ||||
return; | return; | ||||
} | } | ||||
if (m_AnchorType == UPRIGHT || !m_RotZ.IsZero() || !m_RotX.IsZero()) | if (m_AnchorType == UPRIGHT || !m_RotZ.IsZero() || !m_RotX.IsZero() || IsCurrentlyFloating()) | ||||
Not Done Inline Actions(Should we prefer consistent use of alphabetic ordering of the dimensions?) elexis: (Should we prefer consistent use of alphabetic ordering of the dimensions?) | |||||
Not Done Inline ActionsYes wraitii: Yes | |||||
{ | { | ||||
// set the visual rotations to the ones fixed by the interface | // set the visual rotations to the ones fixed by the interface | ||||
m_InterpolatedRotX = m_RotX.ToFloat(); | m_InterpolatedRotX = m_RotX.ToFloat(); | ||||
m_InterpolatedRotZ = m_RotZ.ToFloat(); | m_InterpolatedRotZ = m_RotZ.ToFloat(); | ||||
return; | return; | ||||
} | } | ||||
CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | CmpPtr<ICmpTerrain> cmpTerrain(GetSystemEntity()); | ||||
Show All 26 Lines |
Wildfire Games · Phabricator
Ambiguous definition.
It could mean "the entity is always in a state of floating on water", but I think it is supposed to mean "The Y coordinate will clamp to water height minus float depth if the position is in water" and then CanFloat solve the ambiguity with IsCurrentlyFloating?