Browse Source

Unwarn patch for AppleClang. A few warnings were indeed coding error.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
f943bb4faa

+ 1 - 1
Source/Engine/Audio/SoundSource3D.cpp

@@ -105,8 +105,8 @@ SoundSource3D::SoundSource3D(Context* context) :
     SoundSource(context),
     nearDistance_(DEFAULT_NEARDISTANCE),
     farDistance_(DEFAULT_FARDISTANCE),
-    outerAngle_(DEFAULT_ANGLE),
     innerAngle_(DEFAULT_ANGLE),
+    outerAngle_(DEFAULT_ANGLE),
     rolloffFactor_(DEFAULT_ROLLOFF)
 {
     // Start from zero volume until attenuation properly calculated

+ 2 - 0
Source/Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -234,8 +234,10 @@ Graphics::Graphics(Context* context_) :
     deferredSupport_(false),
     anisotropySupport_(false),
     dxtTextureSupport_(false),
+#ifdef GL_ES_VERSION_2_0
     etcTextureSupport_(false),
     pvrtcTextureSupport_(false),
+#endif
     sRGBSupport_(false),
     sRGBWriteSupport_(false),
     numPrimitives_(0),

+ 2 - 0
Source/Engine/Graphics/OpenGL/OGLGraphics.h

@@ -488,10 +488,12 @@ private:
     bool anisotropySupport_;
     /// DXT format support flag.
     bool dxtTextureSupport_;
+#ifdef GL_ES_VERSION_2_0
     /// ETC1 format support flag.
     bool etcTextureSupport_;
     /// PVRTC formats support flag.
     bool pvrtcTextureSupport_;
+#endif
     /// sRGB conversion on read support flag.
     bool sRGBSupport_;
     /// sRGB conversion on write support flag.

+ 0 - 1
Source/Engine/Graphics/Renderer.cpp

@@ -1471,7 +1471,6 @@ void Renderer::LoadPassShaders(Technique* tech, StringHash type)
     PROFILE(LoadPassShaders);
     
     unsigned shadows = (graphics_->GetHardwareShadowSupport() ? 1 : 0) | (shadowQuality_ & SHADOWQUALITY_HIGH_16BIT);
-    bool isSM3 = graphics_->GetSM3Support();
     
     Vector<SharedPtr<ShaderVariation> >& vertexShaders = pass->GetVertexShaders();
     Vector<SharedPtr<ShaderVariation> >& pixelShaders = pass->GetPixelShaders();

+ 0 - 2
Source/Engine/Graphics/View.cpp

@@ -1178,8 +1178,6 @@ void View::UpdateGeometries()
             
             if (command.type_ == CMD_SCENEPASS)
             {
-                BatchQueue* passQueue = &batchQueues_[command.pass_];
-                
                 SharedPtr<WorkItem> item = queue->GetFreeItem();
                 item->priority_ = M_MAX_UNSIGNED;
                 item->workFunction_ = command.sortMode_ == SORT_FRONTTOBACK ? SortBatchQueueFrontToBackWork : SortBatchQueueBackToFrontWork;

+ 2 - 0
Source/Engine/IO/File.cpp

@@ -54,7 +54,9 @@ static const char* openMode[] =
 };
 #endif
 
+#ifdef ANDROID
 static const unsigned READ_BUFFER_SIZE = 32768;
+#endif
 static const unsigned SKIP_BUFFER_SIZE = 1024;
 
 File::File(Context* context) :

+ 2 - 1
Source/Engine/IO/FileWatcher.cpp

@@ -43,8 +43,9 @@ extern "C" {
 
 namespace Urho3D
 {
-
+#ifndef __APPLE__
 static const unsigned BUFFERSIZE = 4096;
+#endif
 
 FileWatcher::FileWatcher(Context* context) :
     Object(context),

+ 0 - 1
Source/Engine/IO/Serializer.cpp

@@ -208,7 +208,6 @@ bool Serializer::WriteResourceRef(const ResourceRef& value)
 bool Serializer::WriteResourceRefList(const ResourceRefList& value)
 {
     bool success = true;
-    unsigned size = value.names_.Size() * sizeof(StringHash);
     
     success &= WriteStringHash(value.type_);
     success &= WriteVLE(value.names_.Size());

+ 10 - 2
Source/Engine/LuaScript/pkgs/ToCppHook.lua

@@ -91,10 +91,18 @@ function post_output_hook(package)
 
 #include "Precompiled.h"
 #include "tolua++.h"
-#include "ToluaUtils.h"]]
-    )
+#include "ToluaUtils.h"
+
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif]])
 
     WRITE(result)
+    WRITE([[
+#if __clang__
+#pragma clang diagnostic pop
+#endif]])
 end
 
 _push_functions['Component'] = "ToluaPushObject"

+ 1 - 1
Source/Engine/Resource/Image.cpp

@@ -1060,7 +1060,7 @@ Color Image::GetPixelTrilinear(float x, float y, float z) const
     Color colorNear = topColorNear.Lerp(bottomColorNear, yF);
     Color topColorFar = GetPixel(xI, yI, zI + 1).Lerp(GetPixel(xI + 1, yI, zI + 1), xF);
     Color bottomColorFar = GetPixel(xI, yI + 1, zI + 1).Lerp(GetPixel(xI + 1, yI + 1, zI + 1), xF);
-    Color colorFar = topColorNear.Lerp(bottomColorNear, yF);
+    Color colorFar = topColorFar.Lerp(bottomColorFar, yF);
     return colorNear.Lerp(colorFar, zF);
 }
 

+ 4 - 3
Source/Engine/Scene/Scene.cpp

@@ -60,11 +60,11 @@ Scene::Scene(Context* context) :
     localNodeID_(FIRST_LOCAL_ID),
     localComponentID_(FIRST_LOCAL_ID),
     checksum_(0),
+    asyncLoadingMs_(5),
     timeScale_(1.0f),
     elapsedTime_(0),
     smoothingConstant_(DEFAULT_SMOOTHING_CONSTANT),
     snapThreshold_(DEFAULT_SNAP_THRESHOLD),
-    asyncLoadingMs_(5),
     updateEnabled_(true),
     asyncLoading_(false),
     threadedUpdate_(false)
@@ -1072,7 +1072,7 @@ void Scene::PreloadResources(File* file, bool isSceneFile)
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     
     // Read node ID (not needed)
-    unsigned nodeID = file->ReadUInt();
+    /*unsigned nodeID = */file->ReadUInt();
 
     // Read Node or Scene attributes; these do not include any resources
     const Vector<AttributeInfo>* attributes = context_->GetAttributes(isSceneFile ? Scene::GetTypeStatic() : Node::GetTypeStatic());
@@ -1092,7 +1092,8 @@ void Scene::PreloadResources(File* file, bool isSceneFile)
     {
         VectorBuffer compBuffer(*file, file->ReadVLE());
         StringHash compType = compBuffer.ReadStringHash();
-        unsigned compID = compBuffer.ReadUInt();
+        // Read component ID (not needed)
+        /*unsigned compID = */compBuffer.ReadUInt();
         
         attributes = context_->GetAttributes(compType);
         if (attributes)

+ 4 - 4
Source/Engine/Scene/SplinePath.cpp

@@ -34,14 +34,14 @@ extern const char* LOGIC_CATEGORY;
 
 SplinePath::SplinePath(Context* context) :
     Component(context),
+    spline_(BEZIER_CURVE),
     speed_(1.f),
     elapsedTime_(0.f),
-    length_(0.f),
     traveled_(0.f),
-    spline_(BEZIER_CURVE),
-    controlledIdAttr_(0),
+    length_(0.f),
+    dirty_(false),
     controlledNode_(NULL),
-    dirty_(false)
+    controlledIdAttr_(0)
 {
     UpdateNodeIds();
 }

+ 1 - 1
Source/Engine/Script/GraphicsAPI.cpp

@@ -626,7 +626,7 @@ static void RegisterMaterial(asIScriptEngine* engine)
     
     engine->RegisterObjectType("TechniqueEntry", sizeof(TechniqueEntry), asOBJ_VALUE | asOBJ_APP_CLASS_CD);
     engine->RegisterObjectBehaviour("TechniqueEntry", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructTechniqueEntry), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectBehaviour("TechniqueEntry", asBEHAVE_CONSTRUCT, "void f(const TechniqueEntry&in)", asFUNCTION(ConstructTechniqueEntry), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour("TechniqueEntry", asBEHAVE_CONSTRUCT, "void f(const TechniqueEntry&in)", asFUNCTION(ConstructTechniqueEntryCopy), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("TechniqueEntry", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructTechniqueEntry), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("TechniqueEntry", "TechniqueEntry& opAssign(const TechniqueEntry&in)", asMETHOD(TechniqueEntry, operator =), asCALL_THISCALL);
     engine->RegisterObjectMethod("TechniqueEntry", "void set_technique(Technique@+)", asFUNCTION(TechniqueEntrySetTechnique), asCALL_CDECL_OBJLAST);

+ 1 - 1
Source/Engine/Script/ScriptAPIDump.cpp

@@ -513,7 +513,7 @@ void Script::DumpAPI(DumpMode mode)
     
     for (unsigned i = 0; i < sortedEnums.Size(); ++i)
     {
-        int typeId;
+        int typeId = 0;
         if (mode == DOXYGEN)
             Log::WriteRaw("\n### " + String(scriptEngine_->GetEnumByIndex(sortedEnums[i].second_, &typeId)) + "\n\n");
         else if (mode == C_HEADER)

+ 2 - 2
Source/Engine/UI/FontFace.cpp

@@ -34,8 +34,8 @@ namespace Urho3D
 {
 
 FontGlyph::FontGlyph() :
-    used_(false),
-    page_(M_MAX_UNSIGNED)
+    page_(M_MAX_UNSIGNED),
+    used_(false)
 {
 }
 

+ 0 - 4
Source/Engine/UI/FontFaceFreeType.cpp

@@ -130,8 +130,6 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
 
     face_ = face;
 
-    FT_GlyphSlot slot = face->glyph;
-
     FT_UInt glyphIndex;
     unsigned numGlyphs = 0;
     HashMap<unsigned, unsigned> indexToCharMapping;
@@ -147,8 +145,6 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
     LOGDEBUGF("Font face %s (%dpt) has %d glyphs", GetFileName(font_->GetName()).CString(), pointSize, numGlyphs);
 
     // Load each of the glyphs to see the sizes & store other information
-    int maxWidth = 0;
-    int maxHeight = 0;
     int loadMode = ui->GetForceAutoHint() ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_DEFAULT;
     ascender_ = face->size->metrics.ascender >> 6;
     int descender = face->size->metrics.descender >> 6;

+ 3 - 3
Source/Engine/UI/ScrollView.cpp

@@ -46,13 +46,13 @@ ScrollView::ScrollView(Context* context) :
     viewPositionAttr_(IntVector2::ZERO),
     touchScrollSpeed_(Vector2::ZERO),
     touchScrollSpeedMax_(Vector2::ZERO),
-    scrollDeceleration_(30.0f),
-    scrollSnapEpsilon_(M_EPSILON),
-    scrollTouchDown_(false),
     pageStep_(1.0f),
     scrollBarsAutoVisible_(true),
     ignoreEvents_(false),
     resizeContentWidth_(false),
+    scrollDeceleration_(30.0f),
+    scrollSnapEpsilon_(M_EPSILON),
+    scrollTouchDown_(false),
     barScrolling_(false)
 {
     clipChildren_ = true;

+ 4 - 4
Source/Engine/UI/UI.cpp

@@ -79,14 +79,14 @@ UI::UI(Context* context) :
     Object(context),
     rootElement_(new UIElement(context)),
     rootModalElement_(new UIElement(context)),
+    doubleClickInterval_(DEFAULT_DOUBLECLICK_INTERVAL),
+    dragBeginInterval_(DEFAULT_DRAGBEGIN_INTERVAL),
+    defaultToolTipDelay_(DEFAULT_TOOLTIP_DELAY),
+    dragBeginDistance_(DEFAULT_DRAGBEGIN_DISTANCE),
     mouseButtons_(0),
     lastMouseButtons_(0),
     qualifiers_(0),
     maxFontTextureSize_(DEFAULT_FONT_TEXTURE_MAX_SIZE),
-    doubleClickInterval_(DEFAULT_DOUBLECLICK_INTERVAL),
-    dragBeginInterval_(DEFAULT_DRAGBEGIN_INTERVAL),
-    dragBeginDistance_(DEFAULT_DRAGBEGIN_DISTANCE),
-    defaultToolTipDelay_(DEFAULT_TOOLTIP_DELAY),
     initialized_(false),
     usingTouchInput_(false),
     #ifdef WIN32

+ 2 - 2
Source/Engine/Urho2D/Animation2D.cpp

@@ -124,8 +124,8 @@ TimelineKey2D::TimelineKey2D() :
 }
 
 Timeline2D::Timeline2D() :
-    type_(OT_BONE),
-    parent_(-1)
+    parent_(-1),
+    type_(OT_BONE)
 {
 }
 

+ 0 - 2
Source/Engine/Urho2D/AnimationSet2D.cpp

@@ -333,14 +333,12 @@ bool AnimationSet2D::LoadAnimation(const XMLElement& animationElem)
     for (XMLElement keyElem = mainlineElem.GetChild("key"); keyElem; keyElem = keyElem.GetNext("key"))
     {
         MainlineKey2D mainlineKey;
-        int id = keyElem.GetInt("id");
         mainlineKey.time_ = keyElem.GetFloat("time") * 0.001f;
 
         for (XMLElement refElem = keyElem.GetChild(); refElem; refElem = refElem.GetNext())
         {
             Reference2D ref;
             
-            int refId = refElem.GetInt("id");
             if (refElem.GetName() == "bone_ref")
                 ref.type_ = OT_BONE;
             else

+ 0 - 6
Source/Engine/Urho2D/DrawableProxy2D.cpp

@@ -134,12 +134,6 @@ void DrawableProxy2D::UpdateGeometry(const FrameInfo& frame)
         Vertex2D* dest = reinterpret_cast<Vertex2D*>(vertexBuffer_->Lock(0, vertexCount_, true));
         if (dest)
         {
-            Material* material = 0;
-            unsigned iStart = 0;
-            unsigned iCount = 0;
-            unsigned vStart = 0;
-            unsigned vCount = 0;
-
             for (unsigned d = 0; d < drawables_.Size(); ++d)
             {
                 if (!drawables_[d]->GetVisibility())

+ 0 - 3
Source/Engine/Urho2D/TileMapLayer2D.cpp

@@ -356,9 +356,6 @@ void TileMapLayer2D::SetImageLayer(const TmxImageLayer2D* imageLayer)
     if (!imageLayer->GetSprite())
         return;
 
-    TmxFile2D* tmxFile = imageLayer->GetTmxFile();
-    float mapHeight = tmxFile->GetInfo().GetMapHeight();
-
     SharedPtr<Node> imageNode(GetNode()->CreateChild("Tile"));
     imageNode->SetTemporary(true);
     imageNode->SetPosition(imageLayer->GetPosition());

+ 1 - 1
Source/Samples/11_Physics/Physics.cpp

@@ -129,7 +129,7 @@ void Physics::CreateScene()
         // Make the floor physical by adding RigidBody and CollisionShape components. The RigidBody's default
         // parameters make the object static (zero mass.) Note that a CollisionShape by itself will not participate
         // in the physics simulation
-        RigidBody* body = floorNode->CreateComponent<RigidBody>();
+        /*RigidBody* body = */floorNode->CreateComponent<RigidBody>();
         CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
         // Set a box shape of size 1 x 1 x 1 for collision. The shape will be scaled with the scene node scale, so the
         // rendering and physics representation sizes should match (the box model is also 1 x 1 x 1.)

+ 2 - 2
Source/Samples/12_PhysicsStressTest/PhysicsStressTest.cpp

@@ -117,7 +117,7 @@ void PhysicsStressTest::CreateScene()
         floorObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
         
         // Make the floor physical by adding RigidBody and CollisionShape components
-        RigidBody* body = floorNode->CreateComponent<RigidBody>();
+        /*RigidBody* body = */floorNode->CreateComponent<RigidBody>();
         CollisionShape* shape = floorNode->CreateComponent<CollisionShape>();
         shape->SetBox(Vector3::ONE);
     }
@@ -136,7 +136,7 @@ void PhysicsStressTest::CreateScene()
             mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
             mushroomObject->SetCastShadows(true);
 
-            RigidBody* body = mushroomNode->CreateComponent<RigidBody>();
+            /*RigidBody* body = */mushroomNode->CreateComponent<RigidBody>();
             CollisionShape* shape = mushroomNode->CreateComponent<CollisionShape>();
             // By default the highest LOD level will be used, the LOD level can be passed as an optional parameter
             shape->SetTriangleMesh(mushroomObject->GetModel());

+ 2 - 2
Source/Samples/18_CharacterDemo/Character.cpp

@@ -138,8 +138,8 @@ void Character::HandleNodeCollision(StringHash eventType, VariantMap& eventData)
     {
         Vector3 contactPosition = contacts.ReadVector3();
         Vector3 contactNormal = contacts.ReadVector3();
-        float contactDistance = contacts.ReadFloat();
-        float contactImpulse = contacts.ReadFloat();
+        /*float contactDistance = */contacts.ReadFloat();
+        /*float contactImpulse = */contacts.ReadFloat();
         
         // If contact is below node center and mostly vertical, assume it's a ground contact
         if (contactPosition.y_ < (node_->GetPosition().y_ + 1.0f))

+ 0 - 1
Source/Samples/18_CharacterDemo/CharacterDemo.cpp

@@ -256,7 +256,6 @@ void CharacterDemo::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     using namespace Update;
 
-    float timeStep = eventData[P_TIMESTEP].GetFloat();
     Input* input = GetSubsystem<Input>();
 
     if (character_)

+ 0 - 1
Source/Samples/18_CharacterDemo/Touch.cpp

@@ -47,7 +47,6 @@ void Touch::UpdateTouches(Controls& controls) // Called from HandleUpdate
 {
     zoom_ = false; // reset bool
 
-    Graphics* graphics = GetSubsystem<Graphics>();
     Input* input = GetSubsystem<Input>();
 
     // Zoom in/out

+ 0 - 3
Source/Samples/19_VehicleDemo/VehicleDemo.cpp

@@ -157,8 +157,6 @@ void VehicleDemo::CreateScene()
 
 void VehicleDemo::CreateVehicle()
 {
-    ResourceCache* cache = GetSubsystem<ResourceCache>();
-
     Node* vehicleNode = scene_->CreateChild("Vehicle");
     vehicleNode->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
 
@@ -205,7 +203,6 @@ void VehicleDemo::HandleUpdate(StringHash eventType, VariantMap& eventData)
 {
     using namespace Update;
 
-    float timeStep = eventData[P_TIMESTEP].GetFloat();
     Input* input = GetSubsystem<Input>();
 
     if (vehicle_)

+ 2 - 2
Source/Samples/27_Urho2DPhysics/Urho2DPhysics.cpp

@@ -88,7 +88,7 @@ void Urho2DPhysics::CreateScene()
     camera->SetOrthoSize((float)graphics->GetHeight() * PIXEL_SIZE);
 
     // Create 2D physics world component
-    PhysicsWorld2D* physicsWorld = scene_->CreateComponent<PhysicsWorld2D>();
+    /*PhysicsWorld2D* physicsWorld = */scene_->CreateComponent<PhysicsWorld2D>();
 
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     Sprite2D* boxSprite = cache->GetResource<Sprite2D>("Urho2D/Box.png");
@@ -100,7 +100,7 @@ void Urho2DPhysics::CreateScene()
     groundNode->SetScale(Vector3(200.0f, 1.0f, 0.0f));
 
     // Create 2D rigid body for gound
-    RigidBody2D* groundBody = groundNode->CreateComponent<RigidBody2D>();
+    /*RigidBody2D* groundBody = */groundNode->CreateComponent<RigidBody2D>();
 
     StaticSprite2D* groundSprite = groundNode->CreateComponent<StaticSprite2D>();
     groundSprite->SetSprite(boxSprite);

+ 1 - 1
Source/Samples/32_Urho2DConstraints/Urho2DConstraints.cpp

@@ -132,7 +132,7 @@ void Urho2DConstraints::CreateScene()
     for (unsigned j = 0; j<4; ++j)
     {
         Node* edgeNode = scene_->CreateChild("HorizontalEdge");
-        RigidBody2D* edgeBody = edgeNode->CreateComponent<RigidBody2D>();
+        /*RigidBody2D* edgeBody = */edgeNode->CreateComponent<RigidBody2D>();
         CollisionEdge2D* edgeShape = edgeNode->CreateComponent<CollisionEdge2D>();
         edgeShape->SetVertices(Vector2(-5.0f, j*2.0f -3.0f), Vector2(5.0f, j*2.0f -3.0f));
         edgeShape->SetFriction(0.5f); // Set friction