--- /dev/null
+/*******************************************************************************
+ * Copyright 2011 See AUTHORS file.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+#ifndef GdxCollsionObjectBridge_H
+#define GdxCollsionObjectBridge_H
+
+/** @author Xoppa */
+class GdxCollisionObjectBridge {
+public:
+ int userValue;
+};
+
+#endif // GdxCollsionObjectBridge_H
com.badlogic.gdx.utils.Disposable\r
%}\r
\r
+%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") btCollisionObject %{ {\r
+ if (gdxBridge != null) {\r
+ gdxBridge.delete();\r
+ gdxBridge = null;\r
+ }\r
+ if (swigCPtr != 0) {\r
+ instances.remove(swigCPtr);\r
+ if (swigCMemOwn) {\r
+ swigCMemOwn = false;\r
+ gdxBulletJNI.delete_btCollisionObject(swigCPtr);\r
+ }\r
+ swigCPtr = 0;\r
+ }\r
+ }\r
+%}\r
+\r
%typemap(javabody) btCollisionObject %{\r
public final static com.badlogic.gdx.utils.LongMap<btCollisionObject> instances = new com.badlogic.gdx.utils.LongMap<btCollisionObject>();\r
\r
\r
private long swigCPtr;\r
protected boolean swigCMemOwn;\r
+ public GdxCollisionObjectBridge gdxBridge;\r
\r
public Object userData;\r
\r
swigCMemOwn = cMemoryOwn;\r
swigCPtr = cPtr;\r
instances.put(cPtr, this);\r
+ gdxBridge = new GdxCollisionObjectBridge();\r
+ internalSetGdxBridge(gdxBridge);\r
}\r
\r
@Override\r
public void dispose() {\r
- instances.remove(swigCPtr);\r
delete();\r
}\r
\r
\r
%{\r
#include <BulletCollision/CollisionDispatch/btCollisionObject.h>\r
+#include <GdxCustom/GdxCollisionObjectBridge.h>\r
%}\r
%include "BulletCollision/CollisionDispatch/btCollisionObject.h"\r
+%include "GdxCustom/GdxCollisionObjectBridge.h"\r
\r
%extend btCollisionObject {\r
+ void internalSetGdxBridge(GdxCollisionObjectBridge *bridge) {\r
+ $self->setUserPointer(bridge);\r
+ }\r
+ \r
+ GdxCollisionObjectBridge *internalGetGdxBridge() {\r
+ return (GdxCollisionObjectBridge *)($self->getUserPointer());\r
+ }\r
\r
void getAnisotropicFriction(btVector3 & out) {\r
out = $self->getAnisotropicFriction();\r
}\r
\r
int getUserValue() {\r
- int result;\r
- *(const void **)&result = $self->getUserPointer();\r
- return result;\r
+ return ((GdxCollisionObjectBridge*)($self->getUserPointer()))->userValue;;\r
}\r
\r
void setUserValue(int value) {\r
- $self->setUserPointer((void*)value);\r
+ ((GdxCollisionObjectBridge*)($self->getUserPointer()))->userValue = value;\r
}\r
};
\ No newline at end of file