Sorry, I wrote it for testing, and I forgot to remove it.
But MikMikuDance needs to disable diactivation for all physics.How to do it without this line?
please see https://github.com/hkrn/MMDAI/blob/master/MMDME/src/PMDRigidBody.cc line 189
By the way, there are many codes like this:
[java]
btTransform* transA = &btTransform(*mtx1);
jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());
jmeBulletUtil::convert(env, rotA, &transA->getBasis());
[/java]
Is it safe?
I think that it uses transA after destruction of it.
- I will maybe add PhysicsRigidBody.setActivationEnabled(boolean). Just setEnabled(true) your limbs.
- Yes, its a method and no callback, it should be available when it is called.
- I will maybe add PhysicsRigidBody.setActivationEnabled(boolean). Just setEnabled(true) your limbs.
Thanks.
- Yes, its a method and no callback, it should be available when it is called.
But it desn’t work without my patch.
chototsu said:
But it desn't work without my patch.
What doesnt work? I dont get any errors, the ragdoll tests work fine for example.
Your code:
[java]
/*
- Class: com_jme3_bullet_joints_SixDofJoint
- Method: createJoint
- Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject
pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
jmeClasses::initJavaClasses(env);
btRigidBody bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1 = &btMatrix3x3();
btMatrix3x3* mtx2 = &btMatrix3x3();
btTransform* transA = &btTransform(mtx1);
jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());
jmeBulletUtil::convert(env, rotA, &transA->getBasis());
btTransform transB = &btTransform(*mtx2);
jmeBulletUtil::convert(env, pivotB, &transB->getOrigin());
jmeBulletUtil::convert(env, rotB, &transB->getBasis());
[/java]
The transA and transB points same address and it doesn’t work.
The life of transA is end before line 15 and compiler reuses the memory for transB at line 17.
for example: please test this code:
[java]
#include <stdio.h>
class Foo {
public:
char m_name;
Foo(char name) {
m_name = name;
}
~Foo(){
printf(“destructor %sn”, m_name);
}
};
int main(int argc, char argv) {
Foo p1 = &Foo(“foo1”);
Foo p2 = &Foo(“foo2”);
printf("%x %xn", p1, p2);
return 0;
}
[/java]
[java]
$ gcc Test.cpp
test.cpp: In function `int main(int, char)’:
test.cpp:13: warning: taking address of temporary
test.cpp:14: warning: taking address of temporary
$ ./a
destructor foo1
destructor foo2
22cc90 22cc90
[/java]
chototsu said:
The life of transA is end before line 15 and compiler reuses the memory for transB at line 17.
Hm, ok.. But why does it do that? I am friggin using that variable a line later?? Would it work when I'd use not a pointer but the class as variable type?
Your code:
[java]
/*
- Class: com_jme3_bullet_joints_SixDofJoint
- Method: createJoint
- Signature: (JJLcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Lcom/jme3/math/Vector3f;Lcom/jme3/math/Matrix3f;Z)J
/
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
jmeClasses::initJavaClasses(env);
btRigidBody bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1 = &btMatrix3x3();
btMatrix3x3* mtx2 = &btMatrix3x3();
btTransform* transA = &btTransform(mtx1);
jmeBulletUtil::convert(env, pivotA, &transA->getOrigin());
jmeBulletUtil::convert(env, rotA, &transA->getBasis());
btTransform transB = &btTransform(mtx2);
jmeBulletUtil::convert(env, pivotB, &transB->getOrigin());
jmeBulletUtil::convert(env, rotB, &transB->getBasis());
btGeneric6DofConstraint joint = new btGeneric6DofConstraint(*bodyA, *bodyB, *transA, *transB, useLinearReferenceFrameA);
return (long)joint;
}
[/java]
btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, *transA, *transB, useLinearReferenceFrameA);<br />
transA and transB points same address, and transforms of this joint become wrong values.
I chaned it:
[java]
JNIEXPORT jlong JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint
(JNIEnv * env, jobject object, jlong bodyIdA, jlong bodyIdB, jobject pivotA, jobject rotA, jobject pivotB, jobject rotB, jboolean useLinearReferenceFrameA) {
jmeClasses::initJavaClasses(env);
btRigidBody* bodyA = (btRigidBody*) bodyIdA;
btRigidBody* bodyB = (btRigidBody*) bodyIdB;
btMatrix3x3* mtx1 = &btMatrix3x3();
btMatrix3x3* mtx2 = &btMatrix3x3();
btTransform transA;
jmeBulletUtil::convert(env, pivotA, &transA.getOrigin());
jmeBulletUtil::convert(env, rotA, &transA.getBasis());
btTransform transB;
jmeBulletUtil::convert(env, pivotB, &transB.getOrigin());
jmeBulletUtil::convert(env, rotB, &transB.getBasis());
btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
return (long)joint;
}
[/java]
Guess that was a yes. Thanks.
Your code (only revert function:JNICALL Java_com_jme3_bullet_joints_SixDofJoint_createJoint)
What doesnt work? I dont get any errors, the ragdoll tests work fine for example.
When I don’t apply my patch, my MikuMikuDance become like this:
http://chototsumoushinp.dip.jp/miku/souko/test3/pantsu.png
Thats not my code, thats your japanese doll ^^
When I tried to run on Vista 64bit,I got an error.
Exception in thread “main” java.lang.UnsatisfiedLinkError: C:UsersxxxDocumentsjMonkeyProjectsJmeTests3bulletjme.dll: Can’t find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.jme3.system.Natives.extractNativeLib(Natives.java:98)
at com.jme3.system.Natives.extractNativeLibs(Natives.java:181)
at com.jme3.system.JmeSystem.initialize(JmeSystem.java:364)
at com.jme3.system.JmeSystem.newContext(JmeSystem.java:282)
at com.jme3.app.Application.start(Application.java:325)
at com.jme3.app.Application.start(Application.java:307)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:129)
at jme3test.bullet.TestBrickWall.main(TestBrickWall.java:83)
Java Result: 1
How do I use bulletjme.dll?
What dll do I need?
Theres only a dll for 32bit windows at the moment (as stated in the release post) see the thread here for the ongoing discussion about compiling under 64bit windows. Basically if you get it to compile, send us the updated build script.
I deleted the 32 bit DLL because it requires MinGW to be installed on the system, so now everything should work fine as long as you update from SVN or use the latest nightly
Hi.
I succeeded to run my MikuMIkuDance viewer with native bullet both Windows(32/64) and OpenSolaris x86!
Java Web Start is here.
http://chototsumoushinp.dip.jp/miku/souko/test4/
Thanks.
http://chototsumoushinp.dip.jp/miku/souko/test4/nativebullet.png
Hi.
I uploaded native bullet binary.
native module
http://chototsumoushinp.dip.jp/miku/souko/test4/native_bullet_chototsu.jar
java classes
http://chototsumoushinp.dip.jp/miku/souko/test4/native_bullet_chototsu_java.jar
native_bullet.chototsu.jar:
windows/bulletjme.dll
Windows 32bit DLL. I linked libgcc_s statically and it can run both Windows32/64 platform.
solaris/libbulletjme.so
OpenSolaris x86/32 library.
Thanks.
Can you please detail how you compiled the windows 64bit binaries and post patches for the existing build files etc.?
I added build.xml:
[xml]
<linkerarg value="-static"/>
[/xml]