From 9e4a49938365ba68f7eef8b1ee8958296cd7e981 Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Fri, 27 Mar 2015 11:04:23 +0100 Subject: [PATCH 1/3] Fixes assimp/assimp#509 --- .../jassimp/src/jassimp/AiNodeAnim.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java b/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java index 43b4ce66b..34fcb5097 100644 --- a/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java +++ b/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java @@ -3,7 +3,7 @@ Open Asset Import Library - Java Binding (jassimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2012, assimp team +Copyright (c) 2006-2015, assimp team All rights reserved. @@ -68,9 +68,9 @@ import java.nio.ByteOrder; */ public final class AiNodeAnim { /** - * Size of one position key entry (includes padding). + * Size of one position key entry. */ - private static final int POS_KEY_SIZE = 24; + private static final int POS_KEY_SIZE = 20; /** * Size of one rotation key entry. @@ -78,9 +78,9 @@ public final class AiNodeAnim { private static final int ROT_KEY_SIZE = 24; /** - * Size of one scaling key entry (includes padding). + * Size of one scaling key entry. */ - private static final int SCALE_KEY_SIZE = 24; + private static final int SCALE_KEY_SIZE = 20; /** @@ -103,14 +103,13 @@ public final class AiNodeAnim { m_preState = AiAnimBehavior.fromRawValue(preBehavior); m_postState = AiAnimBehavior.fromRawValue(postBehavior); - /* c data is padded -> 24 bytes with 20 bytes data */ m_posKeys = ByteBuffer.allocateDirect(numPosKeys * POS_KEY_SIZE); m_posKeys.order(ByteOrder.nativeOrder()); - m_rotKeys = ByteBuffer.allocateDirect(numRotKeys * 24); + m_rotKeys = ByteBuffer.allocateDirect(numRotKeys * ROT_KEY_SIZE); m_rotKeys.order(ByteOrder.nativeOrder()); - m_scaleKeys = ByteBuffer.allocateDirect(numScaleKeys * 24); + m_scaleKeys = ByteBuffer.allocateDirect(numScaleKeys * SCALE_KEY_SIZE); m_scaleKeys.order(ByteOrder.nativeOrder()); } @@ -141,7 +140,7 @@ public final class AiNodeAnim { * Returns the buffer with position keys of this animation channel.

* * Position keys consist of a time value (double) and a position (3D vector - * of floats), resulting in a total of 24 bytes per entry with padding. + * of floats), resulting in a total of 20 bytes per entry. * The buffer contains {@link #getNumPosKeys()} of these entries.

* * If there are position keys, there will also be at least one @@ -340,7 +339,7 @@ public final class AiNodeAnim { * Returns the buffer with scaling keys of this animation channel.

* * Scaling keys consist of a time value (double) and a 3D vector of floats, - * resulting in a total of 24 bytes per entry with padding. The buffer + * resulting in a total of 20 bytes per entry. The buffer * contains {@link #getNumScaleKeys()} of these entries.

* * If there are scaling keys, there will also be at least one From bdf813ecf0532c13423019a33ebb435a3d5dd42b Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Fri, 27 Mar 2015 18:09:39 +0100 Subject: [PATCH 2/3] new function to get aiVectorKey size --- port/jassimp/jassimp-native/src/jassimp.cpp | 8 ++++++++ port/jassimp/jassimp/src/jassimp/AiNodeAnim.java | 4 ++-- port/jassimp/jassimp/src/jassimp/Jassimp.java | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/port/jassimp/jassimp-native/src/jassimp.cpp b/port/jassimp/jassimp-native/src/jassimp.cpp index 14d9cb2d4..710168e98 100644 --- a/port/jassimp/jassimp-native/src/jassimp.cpp +++ b/port/jassimp/jassimp-native/src/jassimp.cpp @@ -1340,6 +1340,14 @@ static bool loadCameras(JNIEnv *env, const aiScene* cScene, jobject& jScene) } +JNIEXPORT jint JNICALL Java_jassimp_Jassimp_getVKeysize + (JNIEnv *env, jclass jClazz) +{ + const int res = sizeof(aiVectorKey); + + return res; +} + JNIEXPORT jstring JNICALL Java_jassimp_Jassimp_getErrorString (JNIEnv *env, jclass jClazz) { diff --git a/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java b/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java index 34fcb5097..c084accd6 100644 --- a/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java +++ b/port/jassimp/jassimp/src/jassimp/AiNodeAnim.java @@ -70,7 +70,7 @@ public final class AiNodeAnim { /** * Size of one position key entry. */ - private static final int POS_KEY_SIZE = 20; + private static final int POS_KEY_SIZE = Jassimp.getVKeysize(); /** * Size of one rotation key entry. @@ -80,7 +80,7 @@ public final class AiNodeAnim { /** * Size of one scaling key entry. */ - private static final int SCALE_KEY_SIZE = 20; + private static final int SCALE_KEY_SIZE = Jassimp.getVKeysize(); /** diff --git a/port/jassimp/jassimp/src/jassimp/Jassimp.java b/port/jassimp/jassimp/src/jassimp/Jassimp.java index 238456c1d..25b8f6371 100644 --- a/port/jassimp/jassimp/src/jassimp/Jassimp.java +++ b/port/jassimp/jassimp/src/jassimp/Jassimp.java @@ -96,6 +96,13 @@ public final class Jassimp { } + /** + * Returns the size of a struct.

+ * + * @return the result of sizeof call + */ + public static native int getVKeysize(); + /** * Returns a human readable error description.

* From d2d41a8aee2704c849c34dec31abc43871a68338 Mon Sep 17 00:00:00 2001 From: Ser Lev Arris Date: Fri, 27 Mar 2015 19:03:58 +0100 Subject: [PATCH 3/3] jni header update due new function --- port/jassimp/jassimp-native/src/jassimp.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/port/jassimp/jassimp-native/src/jassimp.h b/port/jassimp/jassimp-native/src/jassimp.h index 6f90bb3b6..fadea4fe6 100644 --- a/port/jassimp/jassimp-native/src/jassimp.h +++ b/port/jassimp/jassimp-native/src/jassimp.h @@ -7,6 +7,9 @@ #ifdef __cplusplus extern "C" { #endif +JNIEXPORT jint JNICALL Java_jassimp_Jassimp_getVKeysize + (JNIEnv *, jclass); + /* * Class: jassimp_Jassimp * Method: getErrorString