Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 2877a83

Browse files
committed
New Material property that allows dislodged pixels to relocate in order to avoid compacting, in the same fashion that was previously reserved only for gold
1 parent 89dc424 commit 2877a83

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

Entities/Material.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace RTE {
1010
void Material::Clear() {
1111
m_Index = 0;
1212
m_Priority = 0;
13+
m_Piling = 0;
1314
m_Integrity = 0.0F;
1415
m_Restitution = 0.0F;
1516
m_Friction = 0.0F;
@@ -34,6 +35,7 @@ namespace RTE {
3435

3536
m_Index = reference.m_Index;
3637
m_Priority = reference.m_Priority;
38+
m_Piling = reference.m_Piling;
3739
m_Integrity = reference.m_Integrity;
3840
m_Restitution = reference.m_Restitution;
3941
m_Friction = reference.m_Friction;
@@ -61,6 +63,8 @@ namespace RTE {
6163
reader >> m_Index;
6264
} else if (propName == "Priority") {
6365
reader >> m_Priority;
66+
} else if (propName == "Piling") {
67+
reader >> m_Piling;
6468
} else if (propName == "Integrity" || propName == "StructuralIntegrity") {
6569
reader >> m_Integrity;
6670
} else if (propName == "Restitution" || propName == "Bounce") {
@@ -108,6 +112,8 @@ namespace RTE {
108112
if (m_IsOriginalPreset) {
109113
writer.NewProperty("Priority");
110114
writer << m_Priority;
115+
writer.NewProperty("Piling");
116+
writer << m_Piling;
111117
writer.NewProperty("StructuralIntegrity");
112118
writer << m_Integrity;
113119
writer.NewProperty("Restitution");

Entities/Material.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ namespace RTE {
7070
/// <returns>The drawing priority of this Material.</returns>
7171
int GetPriority() const { return m_Priority; }
7272

73+
/// <summary>
74+
/// Gets the amount of times a dislodged pixel of this Material will attempt to relocate to an open position.
75+
/// </summary>
76+
/// <returns>The amount of attempts at relocating.</returns>
77+
int GetPiling() const { return m_Piling; }
78+
7379
/// <summary>
7480
/// The impulse force that a particle needs to knock loose a terrain pixel of this material. In kg * m/s.
7581
/// </summary>
@@ -152,6 +158,7 @@ namespace RTE {
152158

153159
unsigned char m_Index; //!< Index of this in the material palette. 0 - 255.
154160
int m_Priority; //!< The priority that a pixel of this material has to be displayed. The higher the number, the higher chances that a pixel of this material will be drawn on top of others.
161+
int m_Piling; //! The amount of times a dislodged pixel of this Material will attempt to relocate upwards, when intersecting a terrain pixel of the same Material. TODO: Better property name?
155162

156163
float m_Integrity; //!< The impulse force that a particle needs to knock loose a terrain pixel of this material. In kg * m/s.
157164
float m_Restitution; //!< A scalar value that defines the restitution (elasticity). 1.0 = no kinetic energy is lost in a collision, 0.0 = all energy is lost (plastic).

Managers/MovableMan.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,26 +1954,21 @@ void MovableMan::Update()
19541954
{
19551955
Vector parPos((*parIt)->GetPos().GetFloored());
19561956
Material const * terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.m_X, parPos.m_Y));
1957-
if ((*parIt)->GetDrawPriority() >= terrMat->GetPriority())
1958-
{
1959-
// Gold particle special case to avoid compacting of gold
1960-
if ((*parIt)->GetMaterial()->GetIndex() == c_GoldMaterialID)
1961-
{
1962-
for (int s = 0; terrMat->GetIndex() == c_GoldMaterialID; ++s)
1963-
{
1964-
if (s % 2 == 0)
1965-
parPos.m_Y -= 1.0;
1966-
else
1967-
parPos.m_X += (RandomNum() >= 0.5F ? 1.0F : -1.0F);
1968-
terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.m_X, parPos.m_Y));
1969-
}
1970-
(*parIt)->SetPos(parPos);
1971-
}
1972-
1973-
// (*parIt)->Draw(g_SceneMan.GetTerrain()->GetFGColorBitmap(), Vector(), g_DrawColor, true);
1974-
// (*parIt)->Draw(g_SceneMan.GetTerrain()->GetMaterialBitmap(), Vector(), g_DrawMaterial, true);
1975-
g_SceneMan.GetTerrain()->ApplyMovableObject(*parIt);
1976-
}
1957+
if ((*parIt)->GetDrawPriority() >= terrMat->GetPriority()) {
1958+
int piling = (*parIt)->GetMaterial()->GetPiling();
1959+
if (piling >= 0) {
1960+
for (int s = 0; terrMat->GetIndex() == (*parIt)->GetMaterial()->GetIndex() && s < piling; ++s) {
1961+
if (s % 2 == 0) {
1962+
parPos.m_Y -= 1.0F;
1963+
} else {
1964+
parPos.m_X += (RandomNum() >= 0.5F ? 1.0F : -1.0F);
1965+
}
1966+
terrMat = g_SceneMan.GetMaterialFromID(g_SceneMan.GetTerrain()->GetMaterialPixel(parPos.m_X, parPos.m_Y));
1967+
}
1968+
(*parIt)->SetPos(parPos);
1969+
}
1970+
g_SceneMan.GetTerrain()->ApplyMovableObject(*parIt);
1971+
}
19771972
delete *(parIt++);
19781973
}
19791974
m_Particles.erase(midIt, m_Particles.end());

0 commit comments

Comments
 (0)