Commit 18c06434 authored by Martin Turski's avatar Martin Turski

fixed entity world rotation (? please verify)

parent 9e179144
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <Console.VariableHelpers.h> #include <Console.VariableHelpers.h>
#pragma warning(disable:4996) #pragma warning(disable : 4996)
namespace krt namespace krt
{ {
...@@ -517,6 +517,11 @@ struct sa_iplInstance_t ...@@ -517,6 +517,11 @@ struct sa_iplInstance_t
int lodIndex; // 36, index inside of the .ipl file pointing at the LOD instance. int lodIndex; // 36, index inside of the .ipl file pointing at the LOD instance.
}; };
inline rw::Quat gta_quat_to_rw(const rw::Quat& rotation)
{
return rw::Quat(rotation.w, -rotation.x, -rotation.y, -rotation.z);
}
struct inst_section_manager struct inst_section_manager
{ {
inline void RegisterGTA3Instance( inline void RegisterGTA3Instance(
...@@ -526,19 +531,21 @@ struct inst_section_manager ...@@ -526,19 +531,21 @@ struct inst_section_manager
rw::V3d scale, rw::V3d scale,
rw::Quat rotation) rw::Quat rotation)
{ {
streaming::ident_t universeModelIndex = g_currentParseUniverse->GetModelIndexMapping(modelID);
// I have no actual idea how things are made exactly, but lets just register it somehow. // I have no actual idea how things are made exactly, but lets just register it somehow.
ModelManager::ModelResource* modelInfo = theGame->GetModelManager().GetModelByID(g_currentParseUniverse->GetModelIndexMapping(modelID)); ModelManager::ModelResource* modelInfo = theGame->GetModelManager().GetModelByID(universeModelIndex);
if (!modelInfo) if (!modelInfo)
return; return;
Entity* resultEntity = new Entity(theGame); Entity* resultEntity = new Entity(theGame);
resultEntity->SetModelIndex(modelInfo->GetID()); resultEntity->SetModelIndex(universeModelIndex);
// Assign the matrix. // Assign the matrix.
{ {
rw::Matrix instMatrix = rw::Matrix::makeRotation( rotation ); rw::Matrix instMatrix = rw::Matrix::makeRotation(gta_quat_to_rw(rotation));
instMatrix.rightw = 0; instMatrix.rightw = 0;
instMatrix.atw = 0; instMatrix.atw = 0;
...@@ -564,7 +571,9 @@ struct inst_section_manager ...@@ -564,7 +571,9 @@ struct inst_section_manager
inline void RegisterBinarySAInstance(sa_iplInstance_t& instData) inline void RegisterBinarySAInstance(sa_iplInstance_t& instData)
{ {
ModelManager::ModelResource* modelInfo = theGame->GetModelManager().GetModelByID(g_currentParseUniverse->GetModelIndexMapping(instData.modelIndex)); streaming::ident_t universeModelIndex = g_currentParseUniverse->GetModelIndexMapping(instData.modelIndex);
ModelManager::ModelResource* modelInfo = theGame->GetModelManager().GetModelByID(universeModelIndex);
if (!modelInfo) if (!modelInfo)
return; return;
...@@ -578,14 +587,14 @@ struct inst_section_manager ...@@ -578,14 +587,14 @@ struct inst_section_manager
resultEntity = new Entity(theGame); resultEntity = new Entity(theGame);
resultEntity->SetModelIndex(instData.modelIndex); resultEntity->SetModelIndex(universeModelIndex);
// dont write z buffer flag? // dont write z buffer flag?
} }
// Convert the Quat to a matrix and assign it. // Convert the Quat to a matrix and assign it.
{ {
rw::Matrix instMatrix = rw::Matrix::makeRotation( instData.quatRotation ); rw::Matrix instMatrix = rw::Matrix::makeRotation(gta_quat_to_rw(instData.quatRotation));
instMatrix.rightw = 0; instMatrix.rightw = 0;
instMatrix.atw = 0; instMatrix.atw = 0;
...@@ -657,6 +666,9 @@ struct inst_section_manager ...@@ -657,6 +666,9 @@ struct inst_section_manager
baseEntity->LinkToWorld(theGame->GetWorld()); baseEntity->LinkToWorld(theGame->GetWorld());
} }
// Only do this if we are running gtasa.
if (g_currentParseUniverse->GetConfiguration().gameName == "gtasa")
{
// If certain entities have LOD "models" and their entities do not have lod LODs already. // If certain entities have LOD "models" and their entities do not have lod LODs already.
// Then automatically create lower LODs for them. // Then automatically create lower LODs for them.
for (const lod_inst_entity& inst : this->instances) for (const lod_inst_entity& inst : this->instances)
...@@ -686,6 +698,7 @@ struct inst_section_manager ...@@ -686,6 +698,7 @@ struct inst_section_manager
} }
} }
} }
}
// Success. // Success.
this->instances.clear(); this->instances.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment