Do not draw skinned mesh(node) otherwise glview crashes.

This commit is contained in:
Syoyo Fujita 2018-09-23 18:24:19 +09:00
parent 0c0b993639
commit d180641246
3 changed files with 30 additions and 4 deletions

View File

@ -252,7 +252,7 @@ static void SetupMeshState(tinygltf::Model &model, GLuint progId) {
const tinygltf::BufferView &bufferView = model.bufferViews[i]; const tinygltf::BufferView &bufferView = model.bufferViews[i];
if (bufferView.target == 0) { if (bufferView.target == 0) {
std::cout << "WARN: bufferView.target is zero" << std::endl; std::cout << "WARN: bufferView.target is zero" << std::endl;
continue; // Unsupported bufferView. continue; // Unsupported or not directly used bufferView.
} }
const tinygltf::Buffer &buffer = model.buffers[bufferView.buffer]; const tinygltf::Buffer &buffer = model.buffers[bufferView.buffer];
@ -529,6 +529,13 @@ static void DrawMesh(tinygltf::Model &model, const tinygltf::Mesh &mesh) {
for (; it != itEnd; it++) { for (; it != itEnd; it++) {
assert(it->second >= 0); assert(it->second >= 0);
const tinygltf::Accessor &accessor = model.accessors[it->second]; const tinygltf::Accessor &accessor = model.accessors[it->second];
const tinygltf::BufferView &bufferView = model.bufferViews[accessor.bufferView];
if (bufferView.target == 0) {
// Unsupported or not directly used buffer
continue;
}
glBindBuffer(GL_ARRAY_BUFFER, gBufferState[accessor.bufferView].vb); glBindBuffer(GL_ARRAY_BUFFER, gBufferState[accessor.bufferView].vb);
CheckErrors("bind buffer"); CheckErrors("bind buffer");
int size = 1; int size = 1;
@ -668,7 +675,10 @@ static void DrawNode(tinygltf::Model &model, const tinygltf::Node &node) {
// std::cout << it->first << std::endl; // std::cout << it->first << std::endl;
// FIXME(syoyo): Refactor. // FIXME(syoyo): Refactor.
// DrawCurves(scene, it->second); // DrawCurves(scene, it->second);
DrawMesh(model, model.meshes[node.mesh]);
if ((node.mesh >= 0) && (node.mesh < int(model.meshes.size()))) {
DrawMesh(model, model.meshes[node.mesh]);
}
// Draw child nodes. // Draw child nodes.
for (size_t i = 0; i < node.children.size(); i++) { for (size_t i = 0; i < node.children.size(); i++) {

View File

@ -1,3 +1,8 @@
newoption {
trigger = "asan",
description = "Enable Address Sanitizer(gcc5+ ang clang only)"
}
solution "glview" solution "glview"
-- location ( "build" ) -- location ( "build" )
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
@ -5,6 +10,11 @@ solution "glview"
project "glview" project "glview"
-- Use clang for better asan expericen
if _OPTIONS["asan"] then
toolset "clang"
end
kind "ConsoleApp" kind "ConsoleApp"
language "C++" language "C++"
cppdialect "C++11" cppdialect "C++11"
@ -13,6 +23,12 @@ solution "glview"
includedirs { "../../" } includedirs { "../../" }
configuration { "linux" } configuration { "linux" }
if _OPTIONS["asan"] then
buildoptions { "-fsanitize=address,undefined" }
linkoptions { "-fsanitize=address,undefined" }
end
linkoptions { "`pkg-config --libs glfw3`" } linkoptions { "`pkg-config --libs glfw3`" }
links { "GL", "GLU", "m", "GLEW", "X11", "Xrandr", "Xinerama", "Xi", "Xxf86vm", "Xcursor", "dl" } links { "GL", "GLU", "m", "GLEW", "X11", "Xrandr", "Xinerama", "Xi", "Xxf86vm", "Xcursor", "dl" }

View File

@ -86,7 +86,7 @@ static void vsub(const float *src1, const float *src2, float *dst) {
} }
static void vcopy(const float *v1, float *v2) { static void vcopy(const float *v1, float *v2) {
register int i; int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
v2[i] = v1[i]; v2[i] = v1[i];
} }