2
0
Эх сурвалжийг харах

Subclass SDLActivity so that the package name in SDL JNI code does not need to be changed.
Do not check for duplicate vertices when building triangle collision meshes to avoid a O(n^2) algorithm.

Lasse Öörni 12 жил өмнө
parent
commit
4e618bb80e

+ 1 - 1
Android/AndroidManifest.xml

@@ -7,7 +7,7 @@
     <uses-feature android:glEsVersion="0x00020000" />
     <uses-sdk android:targetSdkVersion="8" android:minSdkVersion="8" />
     <application android:label="@string/app_name" android:icon="@drawable/icon">
-        <activity android:name="SDLActivity"
+        <activity android:name="Urho3D"
                   android:label="@string/app_name"
                   android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                   android:configChanges="keyboardHidden|orientation"

+ 14 - 0
Android/src/com/googlecode/urho3d/Urho3D.java

@@ -0,0 +1,14 @@
+package com.googlecode.urho3d;
+
+import org.libsdl.app.SDLActivity;
+import android.os.*;
+
+public class Urho3D extends SDLActivity {
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+}

+ 1 - 1
Android/src/com/googlecode/urho3d/SDLActivity.java → Android/src/org/libsdl/app/SDLActivity.java

@@ -1,6 +1,6 @@
 // Modified by Lasse Oorni for Urho3D
 
-package com.googlecode.urho3d;
+package org.libsdl.app;
 
 import javax.microedition.khronos.egl.EGL10;
 import javax.microedition.khronos.egl.EGLConfig;

+ 1 - 5
Docs/GettingStarted.dox

@@ -64,11 +64,7 @@ Note that ndk-build builds Urho3D twice, once without hardware floating point in
 
 For a release build, use the "ant release" command instead of "ant debug" and follow the Android SDK instructions on how to sign your APK properly.
 
-By default the Android package for Urho3D is com.googlecode.urho3d. For a real application you must replace this with your own package name. Unfortunately the name has to be replaced in several files:
-
-- Android/AndroidManifest.xml
-- Android/src/com/googlecode/urho3d/SDLActivity.java (rename directories also)
-- ThirdParty/SDL/include/SDL_config_android.h, look for the NATIVE_FUNCTION macro
+By default the Android package for Urho3D is com.googlecode.urho3d. For a real application you must replace this with your own package name. The Urho3D activity subclasses the SDLActivity from org.libsdl.app package, whose name (or the JNI code from SDL library) does not have to be changed.
 
 \section Building_Ios iOS build process
 

+ 2 - 2
Engine/Physics/CollisionShape.cpp

@@ -119,7 +119,7 @@ TriangleMeshData::TriangleMeshData(Model* model, unsigned lodLevel) :
                 const Vector3& v0 = *((const Vector3*)(&vertexData[indices[j] * vertexSize]));
                 const Vector3& v1 = *((const Vector3*)(&vertexData[indices[j + 1] * vertexSize]));
                 const Vector3& v2 = *((const Vector3*)(&vertexData[indices[j + 2] * vertexSize]));
-                meshData_->addTriangle(ToBtVector3(v0), ToBtVector3(v1), ToBtVector3(v2), true);
+                meshData_->addTriangle(ToBtVector3(v0), ToBtVector3(v1), ToBtVector3(v2));
             }
         }
         // 32-bit indices
@@ -132,7 +132,7 @@ TriangleMeshData::TriangleMeshData(Model* model, unsigned lodLevel) :
                 const Vector3& v0 = *((const Vector3*)(&vertexData[indices[j] * vertexSize]));
                 const Vector3& v1 = *((const Vector3*)(&vertexData[indices[j + 1] * vertexSize]));
                 const Vector3& v2 = *((const Vector3*)(&vertexData[indices[j + 2] * vertexSize]));
-                meshData_->addTriangle(ToBtVector3(v0), ToBtVector3(v1), ToBtVector3(v2), true);
+                meshData_->addTriangle(ToBtVector3(v0), ToBtVector3(v1), ToBtVector3(v2));
             }
         }
     }

+ 3 - 7
Readme.txt

@@ -211,13 +211,9 @@ For a release build, use the "ant release" command instead of "ant debug" and
 follow the Android SDK instructions on how to sign your APK properly.
 
 By default the Android package for Urho3D is com.googlecode.urho3d. For a real
-application you must replace this with your own package name. Unfortunately the
-name has to be replaced in several files:
-
-- Android/AndroidManifest.xml
-- Android/src/com/googlecode/urho3d/SDLActivity.java (rename directories also)
-- ThirdParty/SDL/include/SDL_config_android.h, look for the NATIVE_FUNCTION
-  macro
+application you must replace this with your own package name. The Urho3D
+activity subclasses the SDLActivity from org.libsdl.app package, whose name
+(or the JNI code from SDL library) does not have to be changed.
 
 
 iOS build process

+ 2 - 1
ThirdParty/AngelScript/source/as_typeinfo.h

@@ -28,6 +28,7 @@
    [email protected]
 */
 
+// Modified by Lasse Oorni for Urho3D
 
 //
 // as_typeinfo.h
@@ -86,6 +87,6 @@ struct asCTypeInfo
 
 END_AS_NAMESPACE
 
-#endif AS_NO_COMPILER
+#endif
 
 #endif

+ 0 - 3
ThirdParty/SDL/include/SDL_config_android.h

@@ -132,7 +132,4 @@
 #define SDL_VIDEO_RENDER_OGL_ES	1
 #define SDL_VIDEO_RENDER_OGL_ES2	1
 
-/* Define Java package/class name here */
-#define NATIVE_FUNCTION(name) Java_com_googlecode_urho3d_SDLActivity_ ## name
-
 #endif /* _SDL_config_minimal_h */

+ 11 - 11
ThirdParty/SDL/src/core/android/SDL_android.cpp

@@ -147,7 +147,7 @@ extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls, jstring filesDir)
 }
 
 // Resize
-extern "C" void NATIVE_FUNCTION(onNativeResize)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
                                     JNIEnv* env, jclass jcls,
                                     jint width, jint height, jint format)
 {
@@ -155,21 +155,21 @@ extern "C" void NATIVE_FUNCTION(onNativeResize)(
 }
 
 // Keydown
-extern "C" void NATIVE_FUNCTION(onNativeKeyDown)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
                                     JNIEnv* env, jclass jcls, jint keycode)
 {
     Android_OnKeyDown(keycode);
 }
 
 // Keyup
-extern "C" void NATIVE_FUNCTION(onNativeKeyUp)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
                                     JNIEnv* env, jclass jcls, jint keycode)
 {
     Android_OnKeyUp(keycode);
 }
 
 // Touch
-extern "C" void NATIVE_FUNCTION(onNativeTouch)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
                                     JNIEnv* env, jclass jcls,
                                     jint touch_device_id_in, jint pointer_finger_id_in,
                                     jint action, jfloat x, jfloat y, jfloat p)
@@ -178,7 +178,7 @@ extern "C" void NATIVE_FUNCTION(onNativeTouch)(
 }
 
 // Accelerometer
-extern "C" void NATIVE_FUNCTION(onNativeAccel)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
                                     JNIEnv* env, jclass jcls,
                                     jfloat x, jfloat y, jfloat z)
 {
@@ -189,7 +189,7 @@ extern "C" void NATIVE_FUNCTION(onNativeAccel)(
 }
 
 // Quit
-extern "C" void NATIVE_FUNCTION(nativeQuit)(
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit(
                                     JNIEnv* env, jclass cls)
 {    
     // Inject a SDL_QUIT event
@@ -202,7 +202,7 @@ extern "C" void NATIVE_FUNCTION(nativeQuit)(
 }
 
 // Pause
-extern "C" void NATIVE_FUNCTION(nativePause)(
+extern "C" void Java_org_libsdl_app_SDLActivity_nativePause(
                                     JNIEnv* env, jclass cls)
 {
     SDL_Event event;
@@ -221,7 +221,7 @@ extern "C" void NATIVE_FUNCTION(nativePause)(
 }
 
 // Resume
-extern "C" void NATIVE_FUNCTION(nativeResume)(
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeResume(
                                     JNIEnv* env, jclass cls)
 {
     SDL_Event event;
@@ -239,7 +239,7 @@ extern "C" void NATIVE_FUNCTION(nativeResume)(
     }
 }
 
-extern "C" void NATIVE_FUNCTION(nativeRunAudioThread)(
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeRunAudioThread(
                                     JNIEnv* env, jclass cls)
 {
     /* This is the audio thread, with a different environment */
@@ -249,7 +249,7 @@ extern "C" void NATIVE_FUNCTION(nativeRunAudioThread)(
 }
 
 // Surface destroyed
-extern "C" void NATIVE_FUNCTION(onNativeSurfaceDestroyed)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeSurfaceDestroyed(
                                     JNIEnv* env, jclass cls)
 {
     if (Android_Window) {
@@ -258,7 +258,7 @@ extern "C" void NATIVE_FUNCTION(onNativeSurfaceDestroyed)(
 }
 
 // Surface created
-extern "C" void NATIVE_FUNCTION(onNativeSurfaceCreated)(
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeSurfaceCreated(
                                     JNIEnv* env, jclass cls)
 {
     if (Android_Window) {

+ 1 - 1
ThirdParty/SDL/src/main/android/SDL_android_main.cpp

@@ -16,7 +16,7 @@
 extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls, jstring filesDir);
 
 // Start up the SDL app
-extern "C" void NATIVE_FUNCTION(nativeInit)(JNIEnv* env, jclass cls, jstring filesDir)
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jstring filesDir)
 {
     /* This interface could expand with ABI negotiation, calbacks, etc. */
     SDL_Android_Init(env, cls, filesDir);