...
 
Commits (3)
......@@ -4,6 +4,7 @@ See the included LICENSE file
*/
#include "ObjFile.h"
#include "../utils/PlatformUtil.h"
ObjFile::ObjFile() {
}
......@@ -29,17 +30,17 @@ int ObjFile::AddGroup(const std::string& name, const std::vector<Vector3>& verts
}
int ObjFile::LoadForNif(const std::string& fileName, const ObjOptionsImport& options) {
std::fstream base(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
if (base.fail())
std::fstream file;
PlatformUtil::OpenFileStream(file, fileName, std::ios::in | std::ios::binary);
if (file.fail())
return 1;
LoadForNif(base, options);
base.close();
LoadForNif(file, options);
return 0;
}
int ObjFile::LoadForNif(std::fstream& base, const ObjOptionsImport& options) {
ObjData* current = new ObjData();
auto current = new ObjData();
Vector3 v;
Vector2 uv;
......@@ -244,7 +245,8 @@ int ObjFile::LoadForNif(std::fstream& base, const ObjOptionsImport& options) {
int ObjFile::Save(const std::string &fileName) {
std::ofstream file(fileName.c_str(), std::ios_base::binary);
std::fstream file;
PlatformUtil::OpenFileStream(file, fileName, std::ios::out | std::ios::binary);
if (file.fail())
return 1;
......
......@@ -8182,6 +8182,9 @@ void wxGLPanel::SetMeshTextures(const std::string& shapeName, const std::vector<
void wxGLPanel::UpdateMeshVertices(const std::string& shapeName, std::vector<Vector3>* verts, bool updateBVH, bool recalcNormals, bool render, std::vector<Vector2>* uvs) {
int id = gls.GetMeshID(shapeName);
if (id < 0)
return;
gls.Update(id, verts, uvs);
if (updateBVH)
......@@ -8195,11 +8198,18 @@ void wxGLPanel::UpdateMeshVertices(const std::string& shapeName, std::vector<Vec
}
void wxGLPanel::RecalculateMeshBVH(const std::string& shapeName) {
gls.RecalculateMeshBVH(gls.GetMeshID(shapeName));
int id = gls.GetMeshID(shapeName);
if (id < 0)
return;
gls.RecalculateMeshBVH(id);
}
void wxGLPanel::ShowShape(const std::string& shapeName, bool show) {
int id = gls.GetMeshID(shapeName);
if (id < 0)
return;
bool changed = gls.SetMeshVisibility(id, show);
if (changed)
gls.RenderOneFrame();
......
......@@ -78,7 +78,11 @@ public:
void UpdateMeshes(const std::string& shapeName, std::vector<Vector3>* verts, std::vector<Vector2>* uvs = nullptr) {
std::set<int> changed;
gls.Update(gls.GetMeshID(shapeName), verts, uvs, &changed);
int id = gls.GetMeshID(shapeName);
if (id < 0)
return;
gls.Update(id, verts, uvs, &changed);
mesh* m = gls.GetMesh(shapeName);
if (m)
......