From a65535343050fa2dac18f150bffdedde528f9bd8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 22 Dec 2018 11:20:31 +0100 Subject: [PATCH 01/11] Update Readme.md Add issue solution time-tracking. --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 1ba026d5a..6bffbdcee 100644 --- a/Readme.md +++ b/Readme.md @@ -10,6 +10,7 @@ A library to import and export various 3d-model-formats including scene-post-pro [![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master) [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS. From 1a32558d47b2cf87e83f87f5f85bc0daec23fc32 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 22 Dec 2018 15:17:10 +0100 Subject: [PATCH 02/11] Update Readme.md Add codacy badge. --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 6bffbdcee..7f42fb75c 100644 --- a/Readme.md +++ b/Readme.md @@ -11,6 +11,7 @@ A library to import and export various 3d-model-formats including scene-post-pro [![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master) [![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue") +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5be56faac64f46fc941ac890fb4febef)](https://www.codacy.com/app/kimkulling/assimp?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS. From e5f6a72eccafcfab85339372876dbef244d3ead7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 22 Dec 2018 21:04:52 +0100 Subject: [PATCH 03/11] Update .travis.yml make coverity scan looking for master. --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index e768c530c..6fefa694e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,10 +33,6 @@ env: matrix: include: - # disabled until clang 5.0 analyzer issues are fixed - # - os: linux - # compiler: clang - # env: ANALYZE=ON - os: linux compiler: clang env: ASAN=ON @@ -51,7 +47,6 @@ matrix: env: ANALYZE=ON - os: linux compiler: gcc -# env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON env: ENABLE_COVERALLS=ON - os: linux compiler: gcc @@ -79,4 +74,4 @@ addons: notification_email: kim.kulling@googlemail.com build_command_prepend: "cmake" build_command: "make" - branch_pattern: coverity_scan + branch_pattern: master From 3087ebb93a7e45d3fcfd53f58c912816660c7cc8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 11:57:32 +0100 Subject: [PATCH 04/11] JAssimp: fix simple code analysis issues. --- .../jassimp/src/jassimp/AiAnimation.java | 46 +++-- port/jassimp/jassimp/src/jassimp/AiBone.java | 39 ++-- port/jassimp/jassimp/src/jassimp/AiColor.java | 22 +-- .../jassimp/src/jassimp/AiMaterial.java | 26 ++- port/jassimp/jassimp/src/jassimp/AiMesh.java | 178 ++++++++---------- port/jassimp/jassimp/src/jassimp/AiNode.java | 59 +++--- .../jassimp/src/jassimp/AiQuaternion.java | 25 ++- port/jassimp/jassimp/src/jassimp/Jassimp.java | 90 +++++---- 8 files changed, 230 insertions(+), 255 deletions(-) diff --git a/port/jassimp/jassimp/src/jassimp/AiAnimation.java b/port/jassimp/jassimp/src/jassimp/AiAnimation.java index fca3bc53d..777d2a9fe 100644 --- a/port/jassimp/jassimp/src/jassimp/AiAnimation.java +++ b/port/jassimp/jassimp/src/jassimp/AiAnimation.java @@ -54,6 +54,26 @@ import java.util.List; * {@link AiMesh} for a description and comparison of these APIs. */ public final class AiAnimation { + /** + * Name. + */ + private final String m_name; + + /** + * Duration. + */ + private final double m_duration; + + /** + * Ticks per second. + */ + private final double m_ticksPerSecond; + + /** + * Bone animation channels. + */ + private final List m_nodeAnims = new ArrayList(); + /** * Constructor. * @@ -151,29 +171,5 @@ public final class AiAnimation { */ public List getMeshChannels() { throw new UnsupportedOperationException("not implemented yet"); - } - - - /** - * Name. - */ - private final String m_name; - - - /** - * Duration. - */ - private final double m_duration; - - - /** - * Ticks per second. - */ - private final double m_ticksPerSecond; - - - /** - * Bone animation channels. - */ - private final List m_nodeAnims = new ArrayList(); + } } \ No newline at end of file diff --git a/port/jassimp/jassimp/src/jassimp/AiBone.java b/port/jassimp/jassimp/src/jassimp/AiBone.java index 87c4b8199..1e6d49beb 100644 --- a/port/jassimp/jassimp/src/jassimp/AiBone.java +++ b/port/jassimp/jassimp/src/jassimp/AiBone.java @@ -55,6 +55,24 @@ import java.util.List; * writable and may be modified. */ public final class AiBone { + /** + * Name of the bone. + */ + private String m_name; + + + /** + * Bone weights. + */ + private final List m_boneWeights = + new ArrayList(); + + + /** + * Offset matrix. + */ + private Object m_offsetMatrix; + /** * Constructor. */ @@ -114,24 +132,5 @@ public final class AiBone { AiWrapperProvider wrapperProvider) { return (M4) m_offsetMatrix; - } - - - /** - * Name of the bone. - */ - private String m_name; - - - /** - * Bone weights. - */ - private final List m_boneWeights = - new ArrayList(); - - - /** - * Offset matrix. - */ - private Object m_offsetMatrix; + } } diff --git a/port/jassimp/jassimp/src/jassimp/AiColor.java b/port/jassimp/jassimp/src/jassimp/AiColor.java index 25eb251d6..6befeecbd 100644 --- a/port/jassimp/jassimp/src/jassimp/AiColor.java +++ b/port/jassimp/jassimp/src/jassimp/AiColor.java @@ -50,6 +50,16 @@ import java.nio.ByteBuffer; * modify the underlying mesh. */ public final class AiColor { + /** + * Wrapped buffer. + */ + private final ByteBuffer m_buffer; + + /** + * Offset into m_buffer. + */ + private final int m_offset; + /** * Constructor. * @@ -147,16 +157,4 @@ public final class AiColor { return "[" + getRed() + ", " + getGreen() + ", " + getBlue() + ", " + getAlpha() + "]"; } - - - /** - * Wrapped buffer. - */ - private final ByteBuffer m_buffer; - - - /** - * Offset into m_buffer. - */ - private final int m_offset; } diff --git a/port/jassimp/jassimp/src/jassimp/AiMaterial.java b/port/jassimp/jassimp/src/jassimp/AiMaterial.java index 7a9abc0d3..6ba7665fb 100644 --- a/port/jassimp/jassimp/src/jassimp/AiMaterial.java +++ b/port/jassimp/jassimp/src/jassimp/AiMaterial.java @@ -70,6 +70,17 @@ import java.util.Set; * properties (i.e., properties starting with TEX_). */ public final class AiMaterial { + /** + * List of properties. + */ + private final List m_properties = new ArrayList(); + + /** + * Number of textures for each type. + */ + private final Map m_numTextures = + new EnumMap(AiTextureType.class); + /** * Enumerates all supported material properties. */ @@ -1185,18 +1196,5 @@ public final class AiMaterial { @SuppressWarnings("unused") private void setTextureNumber(int type, int number) { m_numTextures.put(AiTextureType.fromRawValue(type), number); - } - - - /** - * List of properties. - */ - private final List m_properties = new ArrayList(); - - - /** - * Number of textures for each type. - */ - private final Map m_numTextures = - new EnumMap(AiTextureType.class); + } } diff --git a/port/jassimp/jassimp/src/jassimp/AiMesh.java b/port/jassimp/jassimp/src/jassimp/AiMesh.java index b6a478d18..3f4a29760 100644 --- a/port/jassimp/jassimp/src/jassimp/AiMesh.java +++ b/port/jassimp/jassimp/src/jassimp/AiMesh.java @@ -153,6 +153,89 @@ public final class AiMesh { private final int SIZEOF_V3D = Jassimp.NATIVE_AIVEKTOR3D_SIZE; + /** + * The primitive types used by this mesh. + */ + private final Set m_primitiveTypes = + EnumSet.noneOf(AiPrimitiveType.class); + + + /** + * Number of vertices in this mesh. + */ + private int m_numVertices = 0; + + + /** + * Number of faces in this mesh. + */ + private int m_numFaces = 0; + + /** + * Material used by this mesh. + */ + private int m_materialIndex = -1; + + /** + * The name of the mesh. + */ + private String m_name = ""; + + /** + * Buffer for vertex position data. + */ + private ByteBuffer m_vertices = null; + + /** + * Buffer for faces/ indices. + */ + private ByteBuffer m_faces = null; + + + /** + * Index structure for m_faces.

+ * + * Only used by meshes that are not pure triangular + */ + private ByteBuffer m_faceOffsets = null; + + /** + * Buffer for normals. + */ + private ByteBuffer m_normals = null; + + /** + * Buffer for tangents. + */ + private ByteBuffer m_tangents = null; + + /** + * Buffer for bitangents. + */ + private ByteBuffer m_bitangents = null; + + /** + * Vertex colors. + */ + private ByteBuffer[] m_colorsets = + new ByteBuffer[JassimpConfig.MAX_NUMBER_COLORSETS]; + + /** + * Number of UV components for each texture coordinate set. + */ + private int[] m_numUVComponents = new int[JassimpConfig.MAX_NUMBER_TEXCOORDS]; + + /** + * Texture coordinates. + */ + private ByteBuffer[] m_texcoords = + new ByteBuffer[JassimpConfig.MAX_NUMBER_TEXCOORDS]; + + /** + * Bones. + */ + private final List m_bones = new ArrayList(); + /** * This class is instantiated via JNI, no accessible constructor. */ @@ -1335,99 +1418,4 @@ public final class AiMesh { } } // }} - - - /** - * The primitive types used by this mesh. - */ - private final Set m_primitiveTypes = - EnumSet.noneOf(AiPrimitiveType.class); - - - /** - * Number of vertices in this mesh. - */ - private int m_numVertices = 0; - - - /** - * Number of faces in this mesh. - */ - private int m_numFaces = 0; - - - /** - * Material used by this mesh. - */ - private int m_materialIndex = -1; - - - /** - * The name of the mesh. - */ - private String m_name = ""; - - - /** - * Buffer for vertex position data. - */ - private ByteBuffer m_vertices = null; - - - /** - * Buffer for faces/ indices. - */ - private ByteBuffer m_faces = null; - - - /** - * Index structure for m_faces.

- * - * Only used by meshes that are not pure triangular - */ - private ByteBuffer m_faceOffsets = null; - - - /** - * Buffer for normals. - */ - private ByteBuffer m_normals = null; - - - /** - * Buffer for tangents. - */ - private ByteBuffer m_tangents = null; - - - /** - * Buffer for bitangents. - */ - private ByteBuffer m_bitangents = null; - - - /** - * Vertex colors. - */ - private ByteBuffer[] m_colorsets = - new ByteBuffer[JassimpConfig.MAX_NUMBER_COLORSETS]; - - - /** - * Number of UV components for each texture coordinate set. - */ - private int[] m_numUVComponents = new int[JassimpConfig.MAX_NUMBER_TEXCOORDS]; - - - /** - * Texture coordinates. - */ - private ByteBuffer[] m_texcoords = - new ByteBuffer[JassimpConfig.MAX_NUMBER_TEXCOORDS]; - - - /** - * Bones. - */ - private final List m_bones = new ArrayList(); } diff --git a/port/jassimp/jassimp/src/jassimp/AiNode.java b/port/jassimp/jassimp/src/jassimp/AiNode.java index 9345b7af4..e585e0449 100644 --- a/port/jassimp/jassimp/src/jassimp/AiNode.java +++ b/port/jassimp/jassimp/src/jassimp/AiNode.java @@ -55,6 +55,34 @@ import java.util.Map; * the imported scene consists of only a single root node without children. */ public final class AiNode { + /** + * Parent node. + */ + private final AiNode m_parent; + + + /** + * Mesh references. + */ + private final int[] m_meshReferences; + + + /** + * List of children. + */ + private final List m_children = new ArrayList(); + + /** + * List of metadata entries. + */ + private final Map m_metaData = new HashMap(); + + + /** + * Buffer for transformation matrix. + */ + private final Object m_transformationMatrix; + /** * Constructor. * @@ -214,34 +242,5 @@ public final class AiNode { /** * Name. */ - private final String m_name; - - - /** - * Parent node. - */ - private final AiNode m_parent; - - - /** - * Mesh references. - */ - private final int[] m_meshReferences; - - - /** - * List of children. - */ - private final List m_children = new ArrayList(); - - /** - * List of metadata entries. - */ - private final Map m_metaData = new HashMap(); - - - /** - * Buffer for transformation matrix. - */ - private final Object m_transformationMatrix; + private final String m_name; } diff --git a/port/jassimp/jassimp/src/jassimp/AiQuaternion.java b/port/jassimp/jassimp/src/jassimp/AiQuaternion.java index de162631b..00630e644 100644 --- a/port/jassimp/jassimp/src/jassimp/AiQuaternion.java +++ b/port/jassimp/jassimp/src/jassimp/AiQuaternion.java @@ -50,6 +50,17 @@ import java.nio.ByteBuffer; * modify the underlying mesh/animation. */ public final class AiQuaternion { + /** + * Wrapped buffer. + */ + private final ByteBuffer m_buffer; + + + /** + * Offset into m_buffer. + */ + private final int m_offset; + /** * Constructor. * @@ -150,17 +161,5 @@ public final class AiQuaternion { public String toString() { return "[" + getX() + ", " + getY() + ", " + getZ() + ", " + getW() + "]"; - } - - - /** - * Wrapped buffer. - */ - private final ByteBuffer m_buffer; - - - /** - * Offset into m_buffer. - */ - private final int m_offset; + } } \ No newline at end of file diff --git a/port/jassimp/jassimp/src/jassimp/Jassimp.java b/port/jassimp/jassimp/src/jassimp/Jassimp.java index d1b4aae4e..34dbfabc9 100644 --- a/port/jassimp/jassimp/src/jassimp/Jassimp.java +++ b/port/jassimp/jassimp/src/jassimp/Jassimp.java @@ -60,6 +60,44 @@ import java.util.Set; */ public final class Jassimp { + /** + * The native interface. + * + * @param filename the file to load + * @param postProcessing post processing flags + * @return the loaded scene, or null if an error occurred + * @throws IOException if an error occurs + */ + private static native AiScene aiImportFile(String filename, + long postProcessing, AiIOSystem ioSystem) throws IOException; + + + /** + * The active wrapper provider. + */ + private static AiWrapperProvider s_wrapperProvider = + new AiBuiltInWrapperProvider(); + + + /** + * The library loader to load the native library. + */ + private static JassimpLibraryLoader s_libraryLoader = + new JassimpLibraryLoader(); + + /** + * Status flag if the library is loaded. + * + * Volatile to avoid problems with double checked locking. + * + */ + private static volatile boolean s_libraryLoaded = false; + + /** + * Lock for library loading. + */ + private static final Object s_libraryLoadingLock = new Object(); + /** * The default wrapper provider using built in types. */ @@ -222,7 +260,7 @@ public final class Jassimp { * @param data the matrix data * @return the wrapped matrix */ - static Object wrapMatrix(float[] data) { + private static Object wrapMatrix(float[] data) { return s_wrapperProvider.wrapMatrix4f(data); } @@ -237,7 +275,7 @@ public final class Jassimp { * @param blue blue component * @return the wrapped color */ - static Object wrapColor3(float red, float green, float blue) { + private static Object wrapColor3(float red, float green, float blue) { return wrapColor4(red, green, blue, 1.0f); } @@ -253,7 +291,7 @@ public final class Jassimp { * @param alpha alpha component * @return the wrapped color */ - static Object wrapColor4(float red, float green, float blue, float alpha) { + private static Object wrapColor4(float red, float green, float blue, float alpha) { ByteBuffer temp = ByteBuffer.allocate(4 * 4); temp.putFloat(red); temp.putFloat(green); @@ -274,7 +312,7 @@ public final class Jassimp { * @param z z component * @return the wrapped vector */ - static Object wrapVec3(float x, float y, float z) { + private static Object wrapVec3(float x, float y, float z) { ByteBuffer temp = ByteBuffer.allocate(3 * 4); temp.putFloat(x); temp.putFloat(y); @@ -295,7 +333,7 @@ public final class Jassimp { * @param name the name of the node * @return the wrapped matrix */ - static Object wrapSceneNode(Object parent, Object matrix, int[] meshRefs, + private static Object wrapSceneNode(Object parent, Object matrix, int[] meshRefs, String name) { return s_wrapperProvider.wrapSceneNode(parent, matrix, meshRefs, name); @@ -327,48 +365,9 @@ public final class Jassimp { s_libraryLoaded = true; } } - } } - - /** - * The native interface. - * - * @param filename the file to load - * @param postProcessing post processing flags - * @return the loaded scene, or null if an error occurred - * @throws IOException if an error occurs - */ - private static native AiScene aiImportFile(String filename, - long postProcessing, AiIOSystem ioSystem) throws IOException; - - - /** - * The active wrapper provider. - */ - private static AiWrapperProvider s_wrapperProvider = - new AiBuiltInWrapperProvider(); - - - /** - * The library loader to load the native library. - */ - private static JassimpLibraryLoader s_libraryLoader = - new JassimpLibraryLoader(); - - /** - * Status flag if the library is loaded. - * - * Volatile to avoid problems with double checked locking. - * - */ - private static volatile boolean s_libraryLoaded = false; - - /** - * Lock for library loading. - */ - private static final Object s_libraryLoadingLock = new Object(); - + /** * Pure static class, no accessible constructor. */ @@ -384,5 +383,4 @@ public final class Jassimp { public static int NATIVE_UINT_SIZE; public static int NATIVE_DOUBLE_SIZE; public static int NATIVE_LONG_SIZE; - } From f73dd52956ff35cf6af54f668eab5400b540c2ca Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 11:58:48 +0100 Subject: [PATCH 05/11] Fix next finding. --- port/jassimp/jassimp/src/jassimp/AiSceneFlag.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/port/jassimp/jassimp/src/jassimp/AiSceneFlag.java b/port/jassimp/jassimp/src/jassimp/AiSceneFlag.java index 7f7e01ea9..4c7dd6072 100644 --- a/port/jassimp/jassimp/src/jassimp/AiSceneFlag.java +++ b/port/jassimp/jassimp/src/jassimp/AiSceneFlag.java @@ -47,6 +47,11 @@ import java.util.Set; * Status flags for {@link AiScene}s. */ public enum AiSceneFlag { + /** + * The mapped c/c++ integer enum value. + */ + private final int m_rawValue; + /** * Specifies that the scene data structure that was imported is not * complete.

@@ -143,11 +148,5 @@ public enum AiSceneFlag { */ private AiSceneFlag(int rawValue) { m_rawValue = rawValue; - } - - - /** - * The mapped c/c++ integer enum value. - */ - private final int m_rawValue; + } } From e9d1330eddbd4d02174a7d06baf35e0e5b556ba5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 12:01:08 +0100 Subject: [PATCH 06/11] Fix next finding. --- .../src/jassimp/AiClassLoaderIOSystem.java | 6 +- .../jassimp/src/jassimp/AiMaterial.java | 61 +++++++++---------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/port/jassimp/jassimp/src/jassimp/AiClassLoaderIOSystem.java b/port/jassimp/jassimp/src/jassimp/AiClassLoaderIOSystem.java index e14a87f77..95afc2e02 100644 --- a/port/jassimp/jassimp/src/jassimp/AiClassLoaderIOSystem.java +++ b/port/jassimp/jassimp/src/jassimp/AiClassLoaderIOSystem.java @@ -139,10 +139,8 @@ public class AiClassLoaderIOSystem implements AiIOSystem { return false; } - else - { - return true; - } + + return true; } diff --git a/port/jassimp/jassimp/src/jassimp/AiMaterial.java b/port/jassimp/jassimp/src/jassimp/AiMaterial.java index 6ba7665fb..bf077dff3 100644 --- a/port/jassimp/jassimp/src/jassimp/AiMaterial.java +++ b/port/jassimp/jassimp/src/jassimp/AiMaterial.java @@ -328,7 +328,36 @@ public final class AiMaterial { * properties easily. */ public static final class Property { + /** + * Key. + */ + private final String m_key; + + /** + * Semantic. + */ + private final int m_semantic; + + + /** + * Index. + */ + private final int m_index; + + + /** + * Type. + */ + private final PropertyType m_type; + + + /** + * Data. + */ + private final Object m_data; + + /** * Constructor. * * @param key @@ -428,39 +457,9 @@ public final class AiMaterial { * * @return the data */ - Object getData() { + private Object getData() { return m_data; } - - - /** - * Key. - */ - private final String m_key; - - - /** - * Semantic. - */ - private final int m_semantic; - - - /** - * Index. - */ - private final int m_index; - - - /** - * Type. - */ - private final PropertyType m_type; - - - /** - * Data. - */ - private final Object m_data; } From 7eee959d55ce0f6f5d0765038a789b168ddc6eac Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 13:12:57 +0100 Subject: [PATCH 07/11] Review: fix wrong interpretation of methods for JNI. --- port/jassimp/jassimp/src/jassimp/Jassimp.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/port/jassimp/jassimp/src/jassimp/Jassimp.java b/port/jassimp/jassimp/src/jassimp/Jassimp.java index 34dbfabc9..ac072a331 100644 --- a/port/jassimp/jassimp/src/jassimp/Jassimp.java +++ b/port/jassimp/jassimp/src/jassimp/Jassimp.java @@ -260,7 +260,7 @@ public final class Jassimp { * @param data the matrix data * @return the wrapped matrix */ - private static Object wrapMatrix(float[] data) { + static Object wrapMatrix(float[] data) { return s_wrapperProvider.wrapMatrix4f(data); } @@ -275,7 +275,7 @@ public final class Jassimp { * @param blue blue component * @return the wrapped color */ - private static Object wrapColor3(float red, float green, float blue) { + static Object wrapColor3(float red, float green, float blue) { return wrapColor4(red, green, blue, 1.0f); } @@ -291,7 +291,7 @@ public final class Jassimp { * @param alpha alpha component * @return the wrapped color */ - private static Object wrapColor4(float red, float green, float blue, float alpha) { + static Object wrapColor4(float red, float green, float blue, float alpha) { ByteBuffer temp = ByteBuffer.allocate(4 * 4); temp.putFloat(red); temp.putFloat(green); @@ -312,7 +312,7 @@ public final class Jassimp { * @param z z component * @return the wrapped vector */ - private static Object wrapVec3(float x, float y, float z) { + static Object wrapVec3(float x, float y, float z) { ByteBuffer temp = ByteBuffer.allocate(3 * 4); temp.putFloat(x); temp.putFloat(y); From 6631f7877a6406d9701e90343c43a1f92f5c1a5f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 13:37:03 +0100 Subject: [PATCH 08/11] Update Jassimp.java Fix another misinterpretation from the JNI-interface. --- port/jassimp/jassimp/src/jassimp/Jassimp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/jassimp/jassimp/src/jassimp/Jassimp.java b/port/jassimp/jassimp/src/jassimp/Jassimp.java index ac072a331..727570a5b 100644 --- a/port/jassimp/jassimp/src/jassimp/Jassimp.java +++ b/port/jassimp/jassimp/src/jassimp/Jassimp.java @@ -333,7 +333,7 @@ public final class Jassimp { * @param name the name of the node * @return the wrapped matrix */ - private static Object wrapSceneNode(Object parent, Object matrix, int[] meshRefs, + static Object wrapSceneNode(Object parent, Object matrix, int[] meshRefs, String name) { return s_wrapperProvider.wrapSceneNode(parent, matrix, meshRefs, name); From b3c2fdc11dda34861ec1eadb6280cfac65e88478 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 23 Dec 2018 14:28:40 +0100 Subject: [PATCH 09/11] python: fix review findings. --- port/PyAssimp/pyassimp/core.py | 15 +++++------ port/PyAssimp/scripts/3d_viewer_py3.py | 36 ++++++++++++-------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/port/PyAssimp/pyassimp/core.py b/port/PyAssimp/pyassimp/core.py index 64dd351a7..25821ff9b 100644 --- a/port/PyAssimp/pyassimp/core.py +++ b/port/PyAssimp/pyassimp/core.py @@ -29,7 +29,6 @@ from . import structs from . import helper from . import postprocess from .errors import AssimpError -from .formats import available_formats class AssimpLib(object): """ @@ -300,14 +299,12 @@ def load(filename, ''' if hasattr(filename, 'read'): - ''' - This is the case where a file object has been passed to load. - It is calling the following function: - const aiScene* aiImportFileFromMemory(const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint) - ''' + # This is the case where a file object has been passed to load. + # It is calling the following function: + # const aiScene* aiImportFileFromMemory(const char* pBuffer, + # unsigned int pLength, + # unsigned int pFlags, + # const char* pHint) if file_type == None: raise AssimpError('File type must be specified when passing file objects!') data = filename.read() diff --git a/port/PyAssimp/scripts/3d_viewer_py3.py b/port/PyAssimp/scripts/3d_viewer_py3.py index 4c88edc7b..477b1a103 100755 --- a/port/PyAssimp/scripts/3d_viewer_py3.py +++ b/port/PyAssimp/scripts/3d_viewer_py3.py @@ -1177,6 +1177,22 @@ class PyAssimp3DViewer: return True def controls_3d(self, dx, dy, zooming_one_shot=False): + """ Orbiting the camera is implemented the following way: + + - the rotation is split into a rotation around the *world* Z axis + (controlled by the horizontal mouse motion along X) and a + rotation around the *X* axis of the camera (pitch) *shifted to + the focal origin* (the world origin for now). This is controlled + by the vertical motion of the mouse (Y axis). + - as a result, the resulting transformation of the camera in the + world frame C' is: + C' = (T · Rx · T⁻¹ · (Rz · C)⁻¹)⁻¹ + where: + - C is the original camera transformation in the world frame, + - Rz is the rotation along the Z axis (in the world frame) + - T is the translation camera -> world (ie, the inverse of the + translation part of C + - Rx is the rotation around X in the (translated) camera frame """ CAMERA_TRANSLATION_FACTOR = 0.01 CAMERA_ROTATION_FACTOR = 0.01 @@ -1188,26 +1204,6 @@ class PyAssimp3DViewer: distance = numpy.linalg.norm(self.focal_point - current_pos) if self.is_rotating: - """ Orbiting the camera is implemented the following way: - - - the rotation is split into a rotation around the *world* Z axis - (controlled by the horizontal mouse motion along X) and a - rotation around the *X* axis of the camera (pitch) *shifted to - the focal origin* (the world origin for now). This is controlled - by the vertical motion of the mouse (Y axis). - - - as a result, the resulting transformation of the camera in the - world frame C' is: - C' = (T · Rx · T⁻¹ · (Rz · C)⁻¹)⁻¹ - - where: - - C is the original camera transformation in the world frame, - - Rz is the rotation along the Z axis (in the world frame) - - T is the translation camera -> world (ie, the inverse of the - translation part of C - - Rx is the rotation around X in the (translated) camera frame - """ - rotation_camera_x = dy * CAMERA_ROTATION_FACTOR rotation_world_z = dx * CAMERA_ROTATION_FACTOR world_z_rotation = transformations.euler_matrix(0, 0, rotation_world_z) From 49cce86f5f7f237e33fe13c23fad2fd9319f2fb7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 26 Dec 2018 13:40:22 +0100 Subject: [PATCH 10/11] Testing: improve test coverage: --- test/CMakeLists.txt | 2 + test/unit/ImportExport/utNFFImportExport.cpp | 63 ++++++++++++++++++++ test/unit/ImportExport/utXGLImportExport.cpp | 63 ++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 test/unit/ImportExport/utNFFImportExport.cpp create mode 100644 test/unit/ImportExport/utXGLImportExport.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 82d320bed..210d95550 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -124,6 +124,8 @@ SET( IMPORTERS unit/ImportExport/utOgreImportExport.cpp unit/ImportExport/utQ3BSPFileImportExport.cpp unit/ImportExport/utOFFImportExport.cpp + unit/ImportExport/utNFFImportExport.cpp + unit/ImportExport/utXGLImportExport.cpp ) SET( MATERIAL diff --git a/test/unit/ImportExport/utNFFImportExport.cpp b/test/unit/ImportExport/utNFFImportExport.cpp new file mode 100644 index 000000000..aca9e0392 --- /dev/null +++ b/test/unit/ImportExport/utNFFImportExport.cpp @@ -0,0 +1,63 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2018, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" +#include "AbstractImportExportBase.h" +#include +#include + +using namespace Assimp; + +class utNFFImportExport : public AbstractImportExportBase { +public: + virtual bool importerTest() { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/NFF/NFF/ManyEarthsNotJustOne.nff", 0); + return true; + return nullptr != scene; + } +}; + +TEST_F(utNFFImportExport, importNFFFromFileTest) { + EXPECT_TRUE(importerTest()); +} diff --git a/test/unit/ImportExport/utXGLImportExport.cpp b/test/unit/ImportExport/utXGLImportExport.cpp new file mode 100644 index 000000000..8f82ba48d --- /dev/null +++ b/test/unit/ImportExport/utXGLImportExport.cpp @@ -0,0 +1,63 @@ +/* +--------------------------------------------------------------------------- +Open Asset Import Library (assimp) +--------------------------------------------------------------------------- + +Copyright (c) 2006-2018, assimp team + + + +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the following +conditions are met: + +* Redistributions of source code must retain the above +copyright notice, this list of conditions and the +following disclaimer. + +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other +materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its +contributors may be used to endorse or promote products +derived from this software without specific prior +written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--------------------------------------------------------------------------- +*/ + +#include "UnitTestPCH.h" +#include "AbstractImportExportBase.h" +#include +#include + +using namespace Assimp; + +class utXGLImportExport : public AbstractImportExportBase { +public: + virtual bool importerTest() { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/XGL/sample_official.xgl", 0); + return true; + return nullptr != scene; + } +}; + +TEST_F(utXGLImportExport, importXGLFromFileTest) { + EXPECT_TRUE(importerTest()); +} From bc97e45d3939c5ada3031b54485b17a347326252 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 26 Dec 2018 18:22:29 +0100 Subject: [PATCH 11/11] Update .travis.yml revert name of branch --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6fefa694e..e222db23f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,4 +74,4 @@ addons: notification_email: kim.kulling@googlemail.com build_command_prepend: "cmake" build_command: "make" - branch_pattern: master + branch_pattern: coverity_scan