Fix for #133
* objects are now copied and textures are updated correctly * also added function to debug objectsdev-ui
parent
7874aca10c
commit
b4700e3bed
|
@ -698,6 +698,82 @@ void CEngine::AddBaseObjQuick(int baseObjRank, const EngineBaseObjDataTier& buff
|
||||||
p1.totalTriangles += p4.vertices.size() - 2;
|
p1.totalTriangles += p4.vertices.size() - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEngine::DebugObject(int objRank)
|
||||||
|
{
|
||||||
|
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||||
|
|
||||||
|
CLogger* l = GetLogger();
|
||||||
|
|
||||||
|
l->Debug("Debug object: %d\n", objRank);
|
||||||
|
if (! m_objects[objRank].used)
|
||||||
|
{
|
||||||
|
l->Debug(" not used\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
l->Debug(" baseObjRank = %d\n", m_objects[objRank].baseObjRank);
|
||||||
|
l->Debug(" visible = %s\n", m_objects[objRank].visible ? "true" : "false");
|
||||||
|
l->Debug(" drawWorld = %s\n", m_objects[objRank].drawWorld ? "true" : "false");
|
||||||
|
l->Debug(" drawFront = %s\n", m_objects[objRank].drawFront ? "true" : "false");
|
||||||
|
l->Debug(" type = %d\n", m_objects[objRank].type);
|
||||||
|
l->Debug(" distance = %f\n", m_objects[objRank].distance);
|
||||||
|
l->Debug(" shadowRank = %d\n", m_objects[objRank].shadowRank);
|
||||||
|
l->Debug(" transparency = %f\n", m_objects[objRank].transparency);
|
||||||
|
|
||||||
|
l->Debug(" baseObj:\n");
|
||||||
|
int baseObjRank = m_objects[objRank].baseObjRank;
|
||||||
|
if (baseObjRank == -1)
|
||||||
|
{
|
||||||
|
l->Debug(" null\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(baseObjRank >= 0 && baseObjRank < static_cast<int>( m_baseObjects.size() ));
|
||||||
|
|
||||||
|
EngineBaseObject& p1 = m_baseObjects[baseObjRank];
|
||||||
|
if (!p1.used)
|
||||||
|
{
|
||||||
|
l->Debug(" not used\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string vecStr;
|
||||||
|
|
||||||
|
vecStr = p1.bboxMin.ToString();
|
||||||
|
l->Debug(" bboxMin: %s\n", vecStr.c_str());
|
||||||
|
vecStr = p1.bboxMax.ToString();
|
||||||
|
l->Debug(" bboxMax: %s\n", vecStr.c_str());
|
||||||
|
l->Debug(" totalTriangles: %d\n", p1.totalTriangles);
|
||||||
|
l->Debug(" radius: %f\n", p1.radius);
|
||||||
|
|
||||||
|
for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
|
||||||
|
{
|
||||||
|
EngineBaseObjTexTier& p2 = p1.next[l2];
|
||||||
|
l->Debug(" l2:\n");
|
||||||
|
|
||||||
|
l->Debug(" tex1: %s (id: %u)\n", p2.tex1Name.c_str(), p2.tex1.id);
|
||||||
|
l->Debug(" tex2: %s (id: %u)\n", p2.tex2Name.c_str(), p2.tex2.id);
|
||||||
|
|
||||||
|
for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
|
||||||
|
{
|
||||||
|
EngineBaseObjLODTier& p3 = p2.next[l3];
|
||||||
|
|
||||||
|
l->Debug(" l3:\n");
|
||||||
|
l->Debug(" lodLevel: %d\n", p3.lodLevel);
|
||||||
|
|
||||||
|
for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
|
||||||
|
{
|
||||||
|
EngineBaseObjDataTier& p4 = p3.next[l4];
|
||||||
|
|
||||||
|
l->Debug(" l4:\n");
|
||||||
|
l->Debug(" type: %d\n", p4.type);
|
||||||
|
l->Debug(" state: %d\n", p4.state);
|
||||||
|
l->Debug(" staticBufferId: %u\n", p4.staticBufferId);
|
||||||
|
l->Debug(" updateStaticBuffer: %s\n", p4.updateStaticBuffer ? "true" : "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CEngine::CreateObject()
|
int CEngine::CreateObject()
|
||||||
{
|
{
|
||||||
|
@ -986,14 +1062,19 @@ void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
|
||||||
|
|
||||||
for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
|
for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
|
||||||
{
|
{
|
||||||
EngineBaseObjTexTier& p2 = p1.next[l2];
|
if (p1.next[l2].tex2Name == tex2Name)
|
||||||
|
|
||||||
if (p2.tex2Name == tex2Name)
|
|
||||||
continue; // already new
|
continue; // already new
|
||||||
|
|
||||||
EngineBaseObjTexTier& newP2 = AddLevel2(p1, p2.tex1Name, tex2Name);
|
std::string tex1Name = p1.next[l2].tex1Name;
|
||||||
newP2.next.insert(newP2.next.end(), p2.next.begin(), p2.next.end());
|
EngineBaseObjTexTier& newP2 = AddLevel2(p1, tex1Name, tex2Name);
|
||||||
p2.next.clear();
|
newP2.next.insert(newP2.next.end(), p1.next[l2].next.begin(), p1.next[l2].next.end());
|
||||||
|
p1.next[l2].next.clear();
|
||||||
|
|
||||||
|
if (!newP2.tex1.Valid())
|
||||||
|
newP2.tex1 = LoadTexture(newP2.tex1Name);
|
||||||
|
|
||||||
|
if (!newP2.tex2.Valid())
|
||||||
|
newP2.tex2 = LoadTexture(newP2.tex2Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ enum EngineRenderState
|
||||||
//! Mode for rendering text
|
//! Mode for rendering text
|
||||||
ENG_RSTATE_TEXT = (1<<18),
|
ENG_RSTATE_TEXT = (1<<18),
|
||||||
//! Only opaque texture, no blending, etc.
|
//! Only opaque texture, no blending, etc.
|
||||||
ENG_RSTATE_OPAQUE_TEXTURE = (1<<19),
|
ENG_RSTATE_OPAQUE_TEXTURE = (1<<19),
|
||||||
//! Only opaque color, no texture, blending, etc.
|
//! Only opaque color, no texture, blending, etc.
|
||||||
ENG_RSTATE_OPAQUE_COLOR = (1<<20)
|
ENG_RSTATE_OPAQUE_COLOR = (1<<20)
|
||||||
};
|
};
|
||||||
|
@ -807,6 +807,9 @@ public:
|
||||||
|
|
||||||
// Objects
|
// Objects
|
||||||
|
|
||||||
|
//! Print debug info about an object
|
||||||
|
void DebugObject(int rank);
|
||||||
|
|
||||||
//! Creates a new object and returns its rank
|
//! Creates a new object and returns its rank
|
||||||
int CreateObject();
|
int CreateObject();
|
||||||
//! Deletes all objects, shadows and ground spots
|
//! Deletes all objects, shadows and ground spots
|
||||||
|
|
|
@ -1556,7 +1556,14 @@ void CPyro::ExploStart()
|
||||||
for (int i = 0; i < OBJECTMAXPART; i++)
|
for (int i = 0; i < OBJECTMAXPART; i++)
|
||||||
{
|
{
|
||||||
int objRank = m_object->GetObjectRank(i);
|
int objRank = m_object->GetObjectRank(i);
|
||||||
if ( objRank == -1 ) continue;
|
if (objRank == -1) continue;
|
||||||
|
|
||||||
|
// TODO: refactor later to material change
|
||||||
|
int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank);
|
||||||
|
int newBaseObjRank = m_engine->CreateBaseObject();
|
||||||
|
m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
|
||||||
|
m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
|
||||||
|
|
||||||
m_engine->ChangeSecondTexture(objRank, "dirty04.png");
|
m_engine->ChangeSecondTexture(objRank, "dirty04.png");
|
||||||
|
|
||||||
Math::Vector pos = m_object->GetPosition(i);
|
Math::Vector pos = m_object->GetPosition(i);
|
||||||
|
@ -1618,6 +1625,13 @@ void CPyro::BurnStart()
|
||||||
{
|
{
|
||||||
int objRank = m_object->GetObjectRank(i);
|
int objRank = m_object->GetObjectRank(i);
|
||||||
if (objRank == -1) continue;
|
if (objRank == -1) continue;
|
||||||
|
|
||||||
|
// TODO: refactor later to material change
|
||||||
|
int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank);
|
||||||
|
int newBaseObjRank = m_engine->CreateBaseObject();
|
||||||
|
m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
|
||||||
|
m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
|
||||||
|
|
||||||
m_engine->ChangeSecondTexture(objRank, "dirty04.png");
|
m_engine->ChangeSecondTexture(objRank, "dirty04.png");
|
||||||
}
|
}
|
||||||
m_engine->LoadTexture("dirty04.png");
|
m_engine->LoadTexture("dirty04.png");
|
||||||
|
|
Loading…
Reference in New Issue