Skip to content

Commit

Permalink
AssimpUtils: when debugging, enable Assimp verbose logging also
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jan 27, 2024
1 parent 7463b01 commit 4f841da
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/
package com.github.stephengold.sport.importers;

import com.github.stephengold.sport.BaseApplication;
import com.github.stephengold.sport.Mesh;
import com.github.stephengold.sport.Utils;
import com.github.stephengold.sport.Vertex;
Expand All @@ -42,6 +43,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import org.lwjgl.PointerBuffer;
import org.lwjgl.assimp.AIColor4D;
import org.lwjgl.assimp.AIFace;
import org.lwjgl.assimp.AILogStream;
import org.lwjgl.assimp.AIMesh;
import org.lwjgl.assimp.AINode;
import org.lwjgl.assimp.AIScene;
Expand Down Expand Up @@ -84,6 +86,15 @@ public static void extractTriangles(String resourceName, int flags,
Collection<Vertex> addVertices) {
ByteBuffer pLoadedBytes = Utils.loadResourceAsBytes(resourceName);

if (BaseApplication.isDebuggingEnabled()) {
AILogStream logStream = AILogStream.create();
String filename = null;
logStream = Assimp.aiGetPredefinedLogStream(
Assimp.aiDefaultLogStream_STDOUT, filename, logStream);
Assimp.aiAttachLogStream(logStream);
Assimp.aiEnableVerboseLogging(true);
}

CharSequence hints;
int dotIndex = resourceName.lastIndexOf(".");
if (dotIndex == -1) {
Expand All @@ -93,6 +104,7 @@ public static void extractTriangles(String resourceName, int flags,
}
AIScene aiScene
= Assimp.aiImportFileFromMemory(pLoadedBytes, flags, hints);
Assimp.aiDetachAllLogStreams();
if (aiScene == null || aiScene.mRootNode() == null) {
String errorString = Assimp.aiGetErrorString();
throw new RuntimeException(
Expand Down

0 comments on commit 4f841da

Please sign in to comment.