Eugene Kozlov 5 år sedan
förälder
incheckning
9f93478e90

+ 0 - 20
Source/Urho3D/AngelScript/Generated_Members_Cn_Cz.cpp

@@ -5721,8 +5721,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     engine->RegisterObjectMethod("CustomGeometry", "void Clear()", asMETHODPR(CustomGeometry, Clear, (), void), asCALL_THISCALL);
     // void CustomGeometry::Commit() | File: ../Graphics/CustomGeometry.h
     engine->RegisterObjectMethod("CustomGeometry", "void Commit()", asMETHODPR(CustomGeometry, Commit, (), void), asCALL_THISCALL);
-    // void CustomGeometry::CreateQuadsFromBuffer(const Vector<Vector3>& pointList, size_t zIterations, size_t thetaIterations, bool connectTail=false) | File: ../Graphics/CustomGeometry.h
-    // Error: type "const Vector<Vector3>&" can not automatically bind
     // explicit CustomGeometry::CustomGeometry(Context* context) | File: ../Graphics/CustomGeometry.h
     engine->RegisterObjectBehaviour("CustomGeometry", asBEHAVE_FACTORY, "CustomGeometry@+ f()", asFUNCTION(CustomGeometry_CustomGeometry_Context), asCALL_CDECL);
     // void CustomGeometry::DefineColor(const Color& color) | File: ../Graphics/CustomGeometry.h
@@ -5741,8 +5739,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     engine->RegisterObjectMethod("CustomGeometry", "void DrawDebugGeometry(DebugRenderer@+, bool)", asMETHODPR(CustomGeometry, DrawDebugGeometry, (DebugRenderer*, bool), void), asCALL_THISCALL);
     // bool CustomGeometry::DrawOcclusion(OcclusionBuffer* buffer) override | File: ../Graphics/CustomGeometry.h
     engine->RegisterObjectMethod("CustomGeometry", "bool DrawOcclusion(OcclusionBuffer@+)", asMETHODPR(CustomGeometry, DrawOcclusion, (OcclusionBuffer*), bool), asCALL_THISCALL);
-    // void CustomGeometry::FillShape(const Vector<Vector3>& shapeList, bool connectTail=true, bool clear=true, int geomNum=0) | File: ../Graphics/CustomGeometry.h
-    // Error: type "const Vector<Vector3>&" can not automatically bind
     // bool Animatable::GetAnimationEnabled() const | File: ../Scene/Animatable.h
     engine->RegisterObjectMethod("CustomGeometry", "bool GetAnimationEnabled() const", asMETHODPR(CustomGeometry, GetAnimationEnabled, () const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("CustomGeometry", "bool get_animationEnabled() const", asMETHODPR(CustomGeometry, GetAnimationEnabled, () const, bool), asCALL_THISCALL);
@@ -5779,8 +5775,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     // const String& Object::GetCategory() const | File: ../Core/Object.h
     engine->RegisterObjectMethod("CustomGeometry", "const String& GetCategory() const", asMETHODPR(CustomGeometry, GetCategory, () const, const String&), asCALL_THISCALL);
     engine->RegisterObjectMethod("CustomGeometry", "const String& get_category() const", asMETHODPR(CustomGeometry, GetCategory, () const, const String&), asCALL_THISCALL);
-    // static Vector<Vector3> CustomGeometry::GetCircleShape(float radius=1, size_t iterations=100, float startTheta=0, float endTheta=2* M_PI) | File: ../Graphics/CustomGeometry.h
-    // Error: type "Vector<Vector3>" can not automatically bind
     // Component* Component::GetComponent(StringHash type) const | File: ../Scene/Component.h
     engine->RegisterObjectMethod("CustomGeometry", "Component@+ GetComponent(StringHash) const", asMETHODPR(CustomGeometry, GetComponent, (StringHash) const, Component*), asCALL_THISCALL);
     // template<class T> T*  Component::GetComponent() const | File: ../Scene/Component.h
@@ -5882,8 +5876,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     engine->RegisterObjectMethod("CustomGeometry", "uint get_shadowMask() const", asMETHODPR(CustomGeometry, GetShadowMask, () const, unsigned), asCALL_THISCALL);
     // float Drawable::GetSortValue() const | File: ../Graphics/Drawable.h
     engine->RegisterObjectMethod("CustomGeometry", "float GetSortValue() const", asMETHODPR(CustomGeometry, GetSortValue, () const, float), asCALL_THISCALL);
-    // static Vector<Vector3> CustomGeometry::GetSquareShape(float size) | File: ../Graphics/CustomGeometry.h
-    // Error: type "Vector<Vector3>" can not automatically bind
     // Object* Object::GetSubsystem(StringHash type) const | File: ../Core/Object.h
     engine->RegisterObjectMethod("CustomGeometry", "Object@+ GetSubsystem(StringHash) const", asMETHODPR(CustomGeometry, GetSubsystem, (StringHash) const, Object*), asCALL_THISCALL);
     // template<class T> T*  Object::GetSubsystem() const | File: ../Core/Object.h
@@ -5972,16 +5964,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     engine->RegisterObjectMethod("CustomGeometry", "bool LoadJSON(const JSONValue&in)", asMETHODPR(CustomGeometry, LoadJSON, (const JSONValue&), bool), asCALL_THISCALL);
     // bool Animatable::LoadXML(const XMLElement& source) override | File: ../Scene/Animatable.h
     engine->RegisterObjectMethod("CustomGeometry", "bool LoadXML(const XMLElement&in)", asMETHODPR(CustomGeometry, LoadXML, (const XMLElement&), bool), asCALL_THISCALL);
-    // void CustomGeometry::MakeCircle(float radius=1, size_t iterations=300, float startTheta=0, float endTheta=2* M_PI, bool clear=true, int geomNum=0) | File: ../Graphics/CustomGeometry.h
-    engine->RegisterObjectMethod("CustomGeometry", "void MakeCircle(float = 1, size_t = 300, float = 0, float = 2 *M_PI, bool = true, int = 0)", asMETHODPR(CustomGeometry, MakeCircle, (float, size_t, float, float, bool, int), void), asCALL_THISCALL);
-    // void CustomGeometry::MakeCircleGraph(const Vector<Pair<float, Urho3D::SharedPtr<Urho3D::Material>>>& parts, int radius=1, int iterations=300) | File: ../Graphics/CustomGeometry.h
-    // Error: type "const Vector<Pair<float, Urho3D::SharedPtr<Urho3D::Material>>>&" can not automatically bind
-    // void CustomGeometry::MakeShape(const Vector<Urho3D::Vector3>& pointList, bool connectTail=true) | File: ../Graphics/CustomGeometry.h
-    // Error: type "const Vector<Urho3D::Vector3>&" can not automatically bind
-    // void CustomGeometry::MakeSphere(float radius=1, size_t iterations=200) | File: ../Graphics/CustomGeometry.h
-    engine->RegisterObjectMethod("CustomGeometry", "void MakeSphere(float = 1, size_t = 200)", asMETHODPR(CustomGeometry, MakeSphere, (float, size_t), void), asCALL_THISCALL);
-    // void CustomGeometry::MakeSquare(float size) | File: ../Graphics/CustomGeometry.h
-    engine->RegisterObjectMethod("CustomGeometry", "void MakeSquare(float)", asMETHODPR(CustomGeometry, MakeSquare, (float), void), asCALL_THISCALL);
     // void Drawable::MarkForUpdate() | File: ../Graphics/Drawable.h
     engine->RegisterObjectMethod("CustomGeometry", "void MarkForUpdate()", asMETHODPR(CustomGeometry, MarkForUpdate, (), void), asCALL_THISCALL);
     // void Drawable::MarkInView(const FrameInfo& frame) | File: ../Graphics/Drawable.h
@@ -6002,8 +5984,6 @@ void ASRegisterGenerated_Members_Cn_Cz(asIScriptEngine* engine)
     engine->RegisterObjectMethod("CustomGeometry", "void PrepareNetworkUpdate()", asMETHODPR(CustomGeometry, PrepareNetworkUpdate, (), void), asCALL_THISCALL);
     // void CustomGeometry::ProcessRayQuery(const RayOctreeQuery& query, PODVector<RayQueryResult>& results) override | File: ../Graphics/CustomGeometry.h
     // Error: type "RayOctreeQuery" can not automatically bind bacause have @nobind mark
-    // void CustomGeometry::ProtrudeShape(const Vector<Vector3>& mShapeList, const Vector<Vector3>& mPointList, bool connectTail=false) | File: ../Graphics/CustomGeometry.h
-    // Error: type "const Vector<Vector3>&" can not automatically bind
     // bool Serializable::ReadDeltaUpdate(Deserializer& source) | File: ../Scene/Serializable.h
     engine->RegisterObjectMethod("CustomGeometry", "bool ReadDeltaUpdate(Deserializer&)", asMETHODPR(CustomGeometry, ReadDeltaUpdate, (Deserializer&), bool), asCALL_THISCALL);
     // bool Serializable::ReadLatestDataUpdate(Deserializer& source) | File: ../Scene/Serializable.h

+ 0 - 309
Source/Urho3D/Graphics/CustomGeometry.cpp

@@ -204,315 +204,6 @@ bool CustomGeometry::DrawOcclusion(OcclusionBuffer* buffer)
     return success;
 }
 
-Vector<Vector3> CustomGeometry::GetCircleShape(float radius, size_t iterations, float startTheta, float endTheta)
-{
-    float stepSize = (endTheta - startTheta) / (float)iterations;
-    Vector<Vector3> shapeList;
-    for (int i = 0; i < iterations; i++)
-    {
-        float curTheta1 = startTheta + ((float)i * stepSize);
-        float curTheta2 = startTheta + ((float)(i + 1) * stepSize);
-        float curX1 = radius * cos(curTheta1);
-        float curY1 = radius * sin(curTheta1);
-        float curX2 = radius * cos(curTheta2);
-        float curY2 = radius * sin(curTheta2);
-
-        shapeList.Push(Urho3D::Vector3(curX1, 0, curY1));
-        shapeList.Push(Urho3D::Vector3(curX2, 0, curY2));
-
-        if (i >= iterations - 1)
-        {
-            float curTheta = 0;
-            if (Abs(endTheta - startTheta) < (2 * M_PI))
-                curTheta = endTheta;
-            float curX = radius * cos(curTheta);
-            float curY = radius * sin(curTheta);
-            shapeList.Push(Vector3(curX, 0, curY));
-        }
-    }
-    return shapeList;
-}
-
-Vector<Vector3> CustomGeometry::GetSquareShape(float size)
-{
-    Vector<Vector3> mSquareList = {
-        Urho3D::Vector3(-(size / 2.0f), 0, (size / 2.0f)), Urho3D::Vector3(-(size / 2.0f), 0, -(size / 2.0f)),
-        Urho3D::Vector3((size / 2.0f), 0, -(size / 2.0f)), Urho3D::Vector3((size / 2.0f), 0, (size / 2.0f))};
-    return mSquareList;
-}
-
-void CustomGeometry::MakeCircle(float radius, size_t iterations, float startTheta, float endTheta, bool clear,
-                                int geomNum)
-{
-    Vector<Vector3> mCircleShape = GetCircleShape(radius, iterations, startTheta, endTheta);
-    FillShape(mCircleShape, false, clear, geomNum);
-}
-
-void CustomGeometry::MakeCircleGraph(const Vector<Pair<float, Urho3D::SharedPtr<Urho3D::Material>>>& parts, int radius,
-                                     int iterations)
-{
-    if (parts.Size() > 0)
-    {
-        float totalWeight = 0;
-        SetNumGeometries(parts.Size());
-        auto it = parts.Begin();
-        while (it != parts.End())
-        {
-            const auto current = (*it);
-            totalWeight += current.first_;
-            it++;
-        }
-
-        it = parts.Begin();
-        float currentStartTheta = 0;
-        float currentEndTheta = 0;
-        int count = 0;
-        while (it != parts.End())
-        {
-            const auto current = (*it);
-            currentEndTheta = ((current.first_ / totalWeight) * (2 * M_PI)) + currentStartTheta;
-            MakeCircle(radius, (iterations / parts.Size()), currentStartTheta, currentEndTheta, false, count);
-            if (current.second_.NotNull())
-                SetMaterial(count, current.second_);
-            it++;
-            count++;
-            currentStartTheta = currentEndTheta;
-        }
-    }
-}
-
-void CustomGeometry::MakeShape(const Vector<Vector3>& pointList, bool connectTail)
-{
-    Clear();
-    SetNumGeometries(1);
-    BeginGeometry(0, Urho3D::PrimitiveType::LINE_STRIP);
-    Vector3 current;
-    Vector3 next;
-    for (size_t i = 0; i < pointList.Size(); i++)
-    {
-        if ((connectTail && i >= pointList.Size() - 1) || i < pointList.Size() - 1)
-        {
-            current = pointList[i];
-            next = pointList[0];
-            if (i < pointList.Size() - 1)
-                next = pointList[i + 1];
-            DefineVertex(current);
-            DefineVertex(next);
-        }
-    }
-    Commit();
-}
-
-void CustomGeometry::FillShape(const Vector<Vector3>& shapeList, bool connectTail, bool clear, int geomNum)
-{
-    if (shapeList.Size() > 0)
-    {
-        int usedGeomNum = geomNum;
-        if (clear)
-        {
-            Clear();
-            SetNumGeometries(1);
-            usedGeomNum = 0;
-        }
-        BeginGeometry(usedGeomNum, PrimitiveType::TRIANGLE_STRIP);
-        auto centerPoint = Vector3(0, 0, 0);
-        if (connectTail)
-        {
-            auto centerPoint = Average(shapeList.Begin(), shapeList.End());
-        }
-        Vector<Vector3> vertices(3);
-        Vector3 current;
-        Vector3 next;
-        Vector3 normal;
-        auto it = shapeList.Begin();
-        auto nextIt = it;
-        while (it != shapeList.End())
-        {
-            nextIt = it + 1;
-            if ((connectTail && nextIt == shapeList.End()) || nextIt != shapeList.End())
-            {
-                current = (*it);
-
-                if (nextIt != shapeList.End())
-                {
-                    next = (*nextIt);
-                }
-                else
-                {
-                    next = (*shapeList.Begin());
-                }
-
-                vertices = {centerPoint, current, next};
-
-                normal = Average(vertices.Begin(), vertices.End());
-                normal.Normalize();
-                normal.Orthogonalize(normal);
-                DefineVertex(vertices.At(0));
-                DefineNormal(normal);
-
-                DefineVertex(vertices.At(1));
-                DefineNormal(normal);
-
-                DefineVertex(vertices.At(2));
-                DefineNormal(normal);
-            }
-            it++;
-        }
-        Commit();
-    }
-}
-
-void CustomGeometry::MakeSphere(float radius, size_t iterations)
-{
-    // Create the geometry buffer
-    float angleStepSize = (2.0f * M_PI) / (float)iterations;
-    Vector<Vector3> m_xyPoints;
-    for (int i = 0; i < iterations; i++)
-    {
-        float curTheta = i * angleStepSize;
-        for (int j = 0; j < iterations; j++)
-        {
-            float curPhi = j * angleStepSize;
-            float curX = radius * cos(curTheta) * sin(curPhi);
-            float curY = radius * sin(curTheta) * sin(curPhi);
-            float curZ = radius * cos(curPhi);
-            m_xyPoints.Push(Vector3(curX, curY, curZ));
-        }
-    }
-
-    CreateQuadsFromBuffer(m_xyPoints, iterations, iterations, true);
-}
-
-void CustomGeometry::ProtrudeShape(const Vector<Vector3>& mShapeList, const Vector<Vector3>& mPointList,
-                                   bool connectTail)
-{
-    Vector3 centerPoint = Average(mShapeList.Begin(), mShapeList.End());
-    Vector3 pointCurrent;
-    Vector3 shapeCurrent;
-    Vector3 shapePointVec;
-    Vector3 shapePointDir;
-    Vector<Vector3> mPointBuffer(mShapeList.Size() * mPointList.Size() + mShapeList.Size());
-
-    Vector<Vector3> mLastShapePos = mShapeList;
-    auto pointIter = mPointList.Begin();
-    auto shapeIter = mLastShapePos.Begin();
-
-    int bufferCount = 0;
-    while (shapeIter != mLastShapePos.End())
-    {
-        mPointBuffer.At(bufferCount) = (*shapeIter);
-        shapeIter++;
-        bufferCount++;
-    }
-
-    int count = 0;
-    while (pointIter != mPointList.End())
-    {
-        shapeIter = mLastShapePos.Begin();
-        pointCurrent = (*pointIter);
-        count = 0;
-        while (shapeIter != mLastShapePos.End())
-        {
-            shapeCurrent = (*shapeIter);
-            if (shapeIter == mLastShapePos.Begin())
-            { // protrude from first point of the shape and create dir Vector to point
-                shapePointVec = pointCurrent - centerPoint;
-                centerPoint = pointCurrent;
-            }
-            // protrude from the rest of the points on the shape to the next point given a dir and length vector
-            shapePointDir = shapePointVec;
-            shapePointDir.Normalize();
-            mLastShapePos[count] = mLastShapePos[count] + shapePointDir * shapePointVec.Length();
-            mPointBuffer.At(bufferCount) = mLastShapePos[count];
-
-            bufferCount++;
-            shapeIter++;
-            count++;
-        }
-        pointIter++;
-    }
-    CreateQuadsFromBuffer(mPointBuffer, mPointList.Size() + 1, mShapeList.Size(), connectTail);
-}
-
-void CustomGeometry::CreateQuadsFromBuffer(const Vector<Vector3>& pointList, size_t zIterations, size_t thetaIterations,
-                                           bool connectTail)
-{
-    if (!connectTail)
-    {
-        SetNumGeometries(3);
-    }
-    else
-    {
-        SetNumGeometries(1);
-    }
-
-    // Create the quads from the buffer
-    BeginGeometry(0, Urho3D::PrimitiveType::TRIANGLE_STRIP);
-    for (size_t i = 0; i < zIterations; i++)
-    {
-        if ((i >= zIterations - 1 && connectTail) || i < zIterations - 1)
-        {
-            for (size_t j = 0; j < thetaIterations; j++)
-            {
-                // if at the end connect to the beginning to complete pass
-                size_t iplus = i + 1;
-                size_t jplus = j + 1;
-                if (i >= zIterations - 1)
-                {
-                    iplus = 0;
-                }
-                if (j >= thetaIterations - 1)
-                {
-                    jplus = 0;
-                }
-                Vector<Vector3> avList;
-                avList = {pointList.At((i * thetaIterations) + j), pointList.At((iplus * thetaIterations) + j),
-                          pointList.At((i * thetaIterations) + jplus)};
-                Vector3 normal = Average(avList.Begin(), avList.End());
-                normal.Normalize();
-                DefineVertex(avList.At(0));
-                DefineVertex(avList.At(1));
-                DefineVertex(avList.At(2));
-                DefineNormal(normal);
-                avList.Clear();
-
-                avList = {pointList.At((i * thetaIterations) + j), pointList.At((iplus * thetaIterations) + j),
-                          pointList.At((iplus * thetaIterations) + jplus)};
-                normal = Average(avList.Begin(), avList.End());
-                normal.Normalize();
-                DefineVertex(avList.At(0));
-                DefineVertex(avList.At(1));
-                DefineVertex(avList.At(2));
-                DefineNormal(normal);
-                avList.Clear();
-            }
-        }
-    }
-    Commit();
-
-    if (!connectTail)
-    {
-        // fill in the head and tail
-        auto tailBegin = pointList.Begin();
-        auto tailEnd = pointList.Begin() + thetaIterations;
-        Vector<Vector3> tail(tailBegin, tailEnd);
-        auto headBegin = pointList.Begin() + pointList.Size() - thetaIterations;
-        auto headEnd = pointList.Begin() + pointList.Size();
-        Vector<Vector3> head(headBegin, headEnd);
-
-        FillShape(tail, true, false, 1);
-        FillShape(head, true, false, 2);
-    }
-}
-
-void CustomGeometry::MakeSquare(float size)
-{
-    Vector<Vector3> mSquareList = {
-        Urho3D::Vector3(-(size / 2.0f), 0, (size / 2.0f)), Urho3D::Vector3(-(size / 2.0f), 0, -(size / 2.0f)),
-        Urho3D::Vector3((size / 2.0f), 0, -(size / 2.0f)), Urho3D::Vector3((size / 2.0f), 0, (size / 2.0f))};
-    FillShape(mSquareList, true);
-}
-
 void CustomGeometry::Clear()
 {
     elementMask_ = MASK_POSITION;

+ 0 - 33
Source/Urho3D/Graphics/CustomGeometry.h

@@ -67,39 +67,6 @@ public:
     /// Draw to occlusion buffer. Return true if did not run out of triangles.
     bool DrawOcclusion(OcclusionBuffer* buffer) override;
 
-    // TODO: Extract this code from CustomGeometry
-    // {
-
-    /// Geometry Shape Helper Functions (normal defaults to (0,1,0)
-
-    /// Shape Creation Functions, can be used as input into protrude shape
-    static Vector<Vector3> GetCircleShape(float radius = 1, size_t iterations = 100, float startTheta = 0, float endTheta = 2 * M_PI);
-    static Vector<Vector3> GetSquareShape(float size);
-
-    /// Make the custom geometry into a circle, change start and stop to make a segment instead
-    /// Set clear=false and geomNum for making multiple circle segments
-    void MakeCircle(float radius = 1, size_t iterations = 300, float startTheta = 0, float endTheta = 2 * M_PI,
-        bool clear = true, int geomNum = 0);
-    /// Draws a shape generated by connecting the points in the input vector (the end point will connect to the start)
-    void MakeShape(const Vector<Urho3D::Vector3>& pointList, bool connectTail = true);
-    /// Makes this custom geometry into a square shape
-    void MakeSquare(float size);
-    /// Produces a circle graph given a vector of paired (weights and materials)
-    void MakeCircleGraph(const Vector<Pair<float, Urho3D::SharedPtr<Urho3D::Material> > >& parts,
-        int radius = 1, int iterations = 300);
-    void MakeSphere(float radius = 1, size_t iterations = 200);
-    /// Protrode a shape along a line (note: the input vector must be a complete shape with the tail connecting to head)
-    /// This function makes this object into the newly generated 3D mesh (works best if the line (point list) is also complete)
-    void ProtrudeShape(const Vector<Vector3> &mShapeList, const Vector<Vector3> &mPointList, bool connectTail = false);
-
-    /// Helper Function Creating 3D Meshes (connectTail = true), connect the endLinePoint to the start)
-    void CreateQuadsFromBuffer(const Vector<Vector3>& pointList, size_t zIterations, size_t thetaIterations, bool connectTail = false);
-    /// Fills a point List shape with triangles
-    void FillShape(const Vector<Vector3>& shapeList, bool connectTail = true, bool clear = true, int geomNum = 0);
-    /// End Shape Generation Helper Functions
-
-    // }
-
     /// Clear all geometries.
     void Clear();
     /// Set number of geometries.