mirror of
https://github.com/rwengine/openrw.git
synced 2025-05-02 14:58:04 +03:00
Refactor SubGeometry to use a vector for storage
+ Use memcpy to populate subgeometry data
This commit is contained in:
parent
d0188880d3
commit
d2e19fbdb3
4 changed files with 10 additions and 16 deletions
|
@ -93,10 +93,10 @@ public:
|
||||||
float ambientIntensity;
|
float ambientIntensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubGeometry {
|
struct SubGeometry {
|
||||||
GLuint start = 0;
|
GLuint start = 0;
|
||||||
size_t material;
|
size_t material;
|
||||||
uint32_t* indices;
|
std::vector<uint32_t> indices;
|
||||||
size_t numIndices;
|
size_t numIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -699,8 +699,8 @@ FileHandle GameData::openFile2(const std::string &name)
|
||||||
auto i = _knownFiles.find(name);
|
auto i = _knownFiles.find(name);
|
||||||
if(i != _knownFiles.end())
|
if(i != _knownFiles.end())
|
||||||
{
|
{
|
||||||
char* data;
|
char* data = nullptr;
|
||||||
size_t length;
|
size_t length = 0;
|
||||||
|
|
||||||
if(i->second.archived)
|
if(i->second.archived)
|
||||||
{
|
{
|
||||||
|
|
|
@ -243,7 +243,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream)
|
||||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER,
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER,
|
||||||
sg.start * sizeof(uint32_t),
|
sg.start * sizeof(uint32_t),
|
||||||
sizeof(uint32_t) * sg.numIndices,
|
sizeof(uint32_t) * sg.numIndices,
|
||||||
sg.indices);
|
sg.indices.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,12 +384,10 @@ void LoaderDFF::readBinMeshPLG(Model *model, const RWBStream &stream)
|
||||||
sg.start = start;
|
sg.start = start;
|
||||||
start += sg.numIndices;
|
start += sg.numIndices;
|
||||||
|
|
||||||
sg.indices = new std::uint32_t[sg.numIndices];
|
sg.indices.resize(sg.numIndices);
|
||||||
|
std::memcpy(sg.indices.data(), data, sizeof(std::uint32_t) * sg.numIndices);
|
||||||
|
data += sizeof(std::uint32_t) * sg.numIndices;
|
||||||
|
|
||||||
for(size_t i = 0; i < sg.numIndices; ++i) {
|
|
||||||
sg.indices[i] = *(std::uint32_t*)data;
|
|
||||||
data += sizeof(std::uint32_t);
|
|
||||||
}
|
|
||||||
model->geometries.back()->subgeom.push_back(sg);
|
model->geometries.back()->subgeom.push_back(sg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,7 @@ Model::Geometry::Geometry()
|
||||||
|
|
||||||
Model::Geometry::~Geometry()
|
Model::Geometry::~Geometry()
|
||||||
{
|
{
|
||||||
for(auto& sg : subgeom) {
|
|
||||||
if( sg.indices ) {
|
|
||||||
delete[] sg.indices;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelFrame::ModelFrame(ModelFrame* parent, glm::mat3 dR, glm::vec3 dT)
|
ModelFrame::ModelFrame(ModelFrame* parent, glm::mat3 dR, glm::vec3 dT)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue