Browse Source

Fixed ScriptInstance.cpp to compile under GCC and LLVM. Better Eclipse build environment setup. General code cleanup. During Editor startup, resets scene when loading requested scene from file specified by the parameter fails.

Wei Tjong Yao 12 years ago
parent
commit
cddaa40080

+ 1 - 2
Bin/Data/Scripts/Editor.as

@@ -60,8 +60,7 @@ void ParseArguments()
     {
         if (arguments[i][0] != '-')
         {
-            LoadScene(arguments[i]);
-            loaded = true;
+            loaded = LoadScene(arguments[i]);
             break;
         }
     }

+ 9 - 6
Bin/Data/Scripts/Editor/EditorScene.as

@@ -186,10 +186,10 @@ void ReloadResources()
         cache.ReloadResource(sceneResources[i]);
 }
 
-void LoadScene(const String&in fileName)
+bool LoadScene(const String&in fileName)
 {
     if (fileName.empty)
-        return;
+        return false;
     
     ui.cursor.shape = CS_BUSY;
     
@@ -197,12 +197,12 @@ void LoadScene(const String&in fileName)
     if (!fileSystem.FileExists(fileName))
     {
         log.Error("No such scene: " + fileName);
-        return;
+        return false;
     }
 
     File file(fileName, FILE_READ);
     if (!file.open)
-        return;
+        return false;
 
     // Clear the old scene
     ClearSelection();
@@ -212,10 +212,11 @@ void LoadScene(const String&in fileName)
     SetResourcePath(GetPath(fileName));
 
     String extension = GetExtension(fileName);
+    bool loaded;
     if (extension != ".xml")
-        editorScene.Load(file);
+        loaded = editorScene.Load(file);
     else
-        editorScene.LoadXML(file);
+        loaded = editorScene.LoadXML(file);
 
     // Always pause the scene, and do updates manually
     editorScene.active = false;
@@ -228,6 +229,8 @@ void LoadScene(const String&in fileName)
     UpdateNodeWindow();
     ResetCamera();
     CreateGizmo();
+
+    return loaded;
 }
 
 void SaveScene(const String&in fileName)

+ 3 - 1
Docs/GettingStarted.dox

@@ -38,7 +38,7 @@ cmake_eclipse.sh on Linux,\n
 cmake_macosx.sh on Mac OS X, and\n
 cmake_gcc.sh on both Linux and Mac OS X.
 -# For Visual Studio, open Urho3D.sln and build the configuration(s) you like. On Windows, using other compilers than Visual Studio is not officially supported. MinGW may work (cmake -G "MinGW Makefiles"), but may lack required DirectX headers. They can be copied to a MinGW installation from the following package: http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz.\n
-For Eclipse on Linux, import the Eclipse's project(s) generated by CMake into the workspace. See "Importing existing projects" in Eclipse Help for detail steps. Select "Build All" or "Build Project" in the menu. Note that Eclipse requires CDT plugin to build C/C++ project.\n
+For Eclipse on Linux, import the Eclipse's project(s) generated by CMake into the workspace. The Eclipse's projects are generated in "Urho3D-Eclipse-build" sub-directory sibling to Urho3D project directory. See "Importing existing projects" in Eclipse Help for detail steps. Select "Build All" or "Build Project" in the menu. Note that Eclipse requires CDT plugin to build C/C++ project.\n
 For GCC, execute make (by default, cmake_gcc.sh specifies to make a RelWithDebInfo build).\n
 For Xcode on Mac OS X, open Urho3D.xcodeproj and select the i386 architecture before building (CMake should already select this when generating the Xcode project). Compiling Urho3D as 64-bit is not supported.
 
@@ -46,6 +46,8 @@ After the build is complete, the programs can be run from the Bin directory.
 
 To run from the Visual Studio debugger, set the Urho3D project as the startup project and enter its relative path and filename into Properties -> Debugging -> Command: ..\\Bin\\Urho3D.exe. Additionally, entering -w into Debugging -> Command Arguments is highly recommended. This enables startup in windowed mode: without it running into an exception or breakpoint will be obnoxious as the mouse cursor will likely be hidden. To actually make Urho3D.exe do something useful, it must be supplied with the name of the script file it should load and run. You can try for example the following arguments: `Scripts/NinjaSnowWar.as -w`. To make the Urho3D examples start faster on Windows & Direct3D9 mode, run CompileAllShaders.bat from the Bin directory first.
 
+To run from Eclipse on Linux, locate and select the Urho3D executable in the Project Explorer. From the menu, choose "Run Configurations" to create a new launch configuration for "C/C++ Application". Switch to "Arguments" tab, specify the argument required by Urho3D executable.
+
 To run from Xcode on Mac OS X, edit the Product Scheme to set "Run" setting to execute "Urho3D" in the "Info" tab. In the "Arguments" tab, specify the arguments required by Urho3D executable. Ensure the check boxes are ticked on the argument entries that you want to be active.
 
 When building with the Windows 8 SDK, copy d3dcompiler_46.dll from C:/Program Files (x86)/Windows Kits/8.0/bin/x86 to Urho3D Bin directory before running.

+ 0 - 1
Engine/Audio/Audio.cpp

@@ -42,7 +42,6 @@ namespace Urho3D
 static const int MIN_BUFFERLENGTH = 20;
 static const int MIN_MIXRATE = 11025;
 static const int MAX_MIXRATE = 48000;
-static const int AUDIO_FPS = 100;
 
 static void SDLAudioCallback(void *userdata, Uint8 *stream, int len);
 

+ 2 - 2
Engine/Container/Str.cpp

@@ -34,8 +34,6 @@ char String::endZero = 0;
 
 const String String::EMPTY;
 
-void PrintArgs(const char *formatString, va_list args);
-
 String::String(const WString& str) :
     length_(0),
     capacity_(0),
@@ -1051,6 +1049,8 @@ String& String::AppendWithFormatArgs(const char* formatString, va_list args)
             }
         }
     }
+
+    return *this;
 }
 
 int String::Compare(const char* lhs, const char* rhs, bool caseSensitive)

+ 1 - 1
Engine/Graphics/CustomGeometry.h

@@ -51,7 +51,7 @@ public:
     /// Construct.
     CustomGeometry(Context* context);
     /// Destruct.
-    ~CustomGeometry();
+    virtual ~CustomGeometry();
     /// Register object factory. Drawable must be registered first.
     static void RegisterObject(Context* context);
     

+ 1 - 3
Engine/IO/FileWatcher.cpp

@@ -112,9 +112,7 @@ bool FileWatcher::StartWatching(const String& pathName, bool watchSubDirs)
     }
 #elif defined(__linux__)
     int flags = IN_CREATE|IN_DELETE|IN_MODIFY|IN_MOVED_FROM|IN_MOVED_TO;
-    int handle;
-    dirHandle_;
-    handle = inotify_add_watch(watchHandle_, pathName.CString(), flags);
+    int handle = inotify_add_watch(watchHandle_, pathName.CString(), flags);
 
     if (handle < 0)
     {

+ 1 - 0
Engine/Network/Connection.cpp

@@ -406,6 +406,7 @@ bool Connection::ProcessMessage(int msgID, MemoryBuffer &msg)
             
         default:
             processed = false;
+            break;
     }
     
     return processed;

+ 2 - 1
Engine/Physics/CollisionShape.cpp

@@ -60,7 +60,7 @@ static const char* typeNames[] =
     "None",
     "Box",
     "Sphere",
-	"StaticPlane",
+    "StaticPlane",
     "Cylinder",
     "Capsule",
     "Cone",
@@ -676,6 +676,7 @@ void CollisionShape::OnMarkedDirty(Node* node)
                 shape_->setLocalScaling(ToBtVector3(Vector3(heightfield->spacing_.x_, 1.0f, heightfield->spacing_.z_) *
                     newWorldScale * size_));
             }
+            break;
         
         default:
             break;

+ 0 - 2
Engine/Physics/RigidBody.cpp

@@ -46,8 +46,6 @@ namespace Urho3D
 static const float DEFAULT_MASS = 0.0f;
 static const float DEFAULT_FRICTION = 0.5f;
 static const float DEFAULT_RESTITUTION = 0.0f;
-static const float DEFAULT_LINEAR_REST_THRESHOLD = 0.8f;
-static const float DEFAULT_ANGULAR_REST_THRESHOLD = 1.0f;
 static const unsigned DEFAULT_COLLISION_LAYER = 0x1;
 static const unsigned DEFAULT_COLLISION_MASK = M_MAX_UNSIGNED;
 

+ 2 - 0
Engine/Script/ScriptEventListener.h

@@ -31,6 +31,8 @@ namespace Urho3D
 class ScriptEventListener
 {
 public:
+    /// Destruct
+    virtual ~ScriptEventListener() {};
     /// Add a scripted event handler. Called by script exposed version of SubscribeToEvent().
     virtual void AddEventHandler(StringHash eventType, const String& handlerName) = 0;
     /// Add a scripted event handler for a specific sender. Called by script exposed version of SubscribeToEvent().

+ 4 - 2
Engine/Script/ScriptFile.cpp

@@ -130,7 +130,8 @@ bool ScriptFile::Load(Deserializer& source)
     // Check if this file is precompiled bytecode
     if (source.ReadFileID() == "ASBC")
     {
-        if (scriptModule_->LoadByteCode(&ByteCodeDeserializer(source)) >= 0)
+        ByteCodeDeserializer deserializer = ByteCodeDeserializer(source);
+        if (scriptModule_->LoadByteCode(&deserializer) >= 0)
         {
             LOGINFO("Loaded script module " + GetName() + " from bytecode");
             compiled_ = true;
@@ -353,7 +354,8 @@ bool ScriptFile::SaveByteCode(Serializer& dest)
     if (compiled_)
     {
         dest.WriteFileID("ASBC");
-        return scriptModule_->SaveByteCode(&ByteCodeSerializer(dest), true) >= 0;
+        ByteCodeSerializer serializer = ByteCodeSerializer(dest);
+        return scriptModule_->SaveByteCode(&serializer, true) >= 0;
     }
     else
         return false;

+ 12 - 5
Readme.txt

@@ -146,10 +146,12 @@ supported. MinGW may work (cmake -G "MinGW Makefiles"), but may lack required
 DirectX headers. They can be copied to a MinGW installation from the following 
 package: http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz
 
-For Eclipse on Linux, import the Eclipse's project(s) generated by CMake into the
-workspace. See "Importing existing projects" in Eclipse Help for detail steps.
-Select "Build All" or "Build Project" in the menu.
-Note that Eclipse requires CDT plugin to build C/C++ project.
+For Eclipse on Linux, import the Eclipse's project(s) generated by CMake into
+the workspace. The Eclipse's projects are generated in "Urho3D-Eclipse-build"
+sub-directory sibling to Urho3D project directory.
+See "Importing existing projects" in Eclipse Help for detail steps. Select
+"Build All" or "Build Project" in the menu. Note that Eclipse requires CDT
+plugin to build C/C++ project.
 
 For GCC, execute make (by default, cmake_gcc.sh specifies to make a
 RelWithDebInfo build).
@@ -174,6 +176,11 @@ following arguments: Scripts/NinjaSnowWar.as -w
 To make the Urho3D examples start faster on Windows & Direct3D9 mode, run
 CompileAllShaders.bat from the Bin directory first.
 
+To run from Eclipse on Linux, locate and select the Urho3D executable in the
+Project Explorer. From the menu, choose "Run Configurations" to create a new
+launch configuration for "C/C++ Application". Switch to "Arguments" tab, specify
+the argument required by Urho3D executable.
+
 To run from Xcode on Mac OS X, edit the Product Scheme to set "Run" setting
 to execute "Urho3D" in the "Info" tab. In the "Arguments" tab, specify the
 arguments required by Urho3D executable. Ensure the check boxes are ticked on
@@ -304,4 +311,4 @@ V1.22   - Configurable render path replaces hardcoded forward/prepass/deferred
         - Separate physics collision start & end events.
         - Visual Studio 2012, Eclipse & Xcode build support.
         - Many bugfixes, including iOS 6 orientation & shadow mapping bugfixes,
-          skinning on some Android devices.
+          skinning on some Android devices.

+ 8 - 7
cmake_eclipse.sh

@@ -1,16 +1,17 @@
 rm -f CMakeCache.txt
-mkdir -p Urho3D/Release Urho3D/Debug Urho3D/RelWithDebInfo
-cmake -E chdir Urho3D/Release cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../..
-cmake -E chdir Urho3D/Debug cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ../..
-cmake -E chdir Urho3D/RelWithDebInfo cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo ../..
+proj=`pwd`
+mkdir -p ../Urho3D-Eclipse-build/Release ../Urho3D-Eclipse-build/Debug ../Urho3D-Eclipse-build/RelWithDebInfo
+cmake -E chdir ../Urho3D-Eclipse-build/Release cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release $proj
+cmake -E chdir ../Urho3D-Eclipse-build/Debug cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug $proj
+cmake -E chdir ../Urho3D-Eclipse-build/RelWithDebInfo cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo $proj
 sed -i.bak 's/OpenGL/Direct3D9/g' Doxyfile
 #
 # Create symbolic links in the respective Eclipse configuration subdir to allow running Urho3D within the Eclipse itself
-cd Urho3D
+cd ../Urho3D-Eclipse-build
 for conf in Debug RelWithDebInfo Release; do
 if [ ! -d $conf/Urho3D/CoreData ]
 then
-    ln -s ../../../Bin/CoreData $conf/Urho3D/.
-    ln -s ../../../Bin/Data $conf/Urho3D/.
+    ln -s $proj/Bin/CoreData $conf/Urho3D/.
+    ln -s $proj/Bin/Data $conf/Urho3D/.
 fi
 done