Removes Triangulate from Code/Editor
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
||||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "EditorDefs.h"
|
|
||||||
|
|
||||||
#include "Triangulate.h"
|
|
||||||
|
|
||||||
// this file is essentially a wrapper for a portion of the MIT-licenced
|
|
||||||
// ConvexDecomposition library by John W. Ratcliff mailto:jratcliffscarab@gmail.com.
|
|
||||||
// it contains no code from that library, it just provides it with the required types, then includes the
|
|
||||||
// portion we need.
|
|
||||||
|
|
||||||
static const float TRIANGULATION_EPSILON = 0.0000000001f;
|
|
||||||
|
|
||||||
#define MEMALLOC_MALLOC malloc
|
|
||||||
#define MEMALLOC_FREE free
|
|
||||||
|
|
||||||
namespace TriInternal
|
|
||||||
{
|
|
||||||
class TVec;
|
|
||||||
typedef double NxF64;
|
|
||||||
typedef float NxF32;
|
|
||||||
typedef unsigned char NxU8;
|
|
||||||
typedef unsigned int NxU32;
|
|
||||||
typedef int NxI32;
|
|
||||||
typedef unsigned int TU32;
|
|
||||||
|
|
||||||
typedef std::vector< TVec > TVecVector;
|
|
||||||
typedef std::vector< NxU32 > TU32Vector;
|
|
||||||
#include "Contrib/NvFloatMath.inl"
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef MEMALLOC_MALLOC
|
|
||||||
#undef MEMALLOC_FREE
|
|
||||||
|
|
||||||
namespace Triangulator
|
|
||||||
{
|
|
||||||
// given the contour of a triangle, triangulate it, and return the result
|
|
||||||
// as a set of triangles
|
|
||||||
// return false if you fail to triangulate it.
|
|
||||||
bool Triangulate(const VectorOfVectors& contour, VectorOfVectors& result)
|
|
||||||
{
|
|
||||||
TriInternal::CTriangulator tri;
|
|
||||||
for (auto pt : contour)
|
|
||||||
{
|
|
||||||
tri.addPoint(pt.x, pt.y, pt.z);
|
|
||||||
}
|
|
||||||
TriInternal::NxU32 tricount = 0;
|
|
||||||
TriInternal::NxU32* indices = tri.triangulate(tricount, TRIANGULATION_EPSILON);
|
|
||||||
if (!indices)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TriInternal::NxU32 currentIdx = 0; currentIdx < tricount * 3; ++currentIdx)
|
|
||||||
{
|
|
||||||
TriInternal::NxU32 indexValue = *indices++;
|
|
||||||
result.push_back(contour[indexValue]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.size() > 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
||||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef CRYINCLUDE_EDITOR_UTIL_TRIANGULATE_H
|
|
||||||
#define CRYINCLUDE_EDITOR_UTIL_TRIANGULATE_H
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "Cry_Vector3.h"
|
|
||||||
|
|
||||||
// you pass in a vector of vec3 (the contour of a shape) and it outputs a vector of vec3 (being the triangles)
|
|
||||||
|
|
||||||
namespace Triangulator
|
|
||||||
{
|
|
||||||
typedef std::vector< Vec3 > VectorOfVectors;
|
|
||||||
bool Triangulate(const VectorOfVectors& contour, VectorOfVectors& result);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -648,8 +648,6 @@ set(FILES
|
|||||||
Util/PredefinedAspectRatios.h
|
Util/PredefinedAspectRatios.h
|
||||||
Util/StringHelpers.cpp
|
Util/StringHelpers.cpp
|
||||||
Util/StringHelpers.h
|
Util/StringHelpers.h
|
||||||
Util/Triangulate.cpp
|
|
||||||
Util/Triangulate.h
|
|
||||||
Util/Util.h
|
Util/Util.h
|
||||||
Util/XmlArchive.cpp
|
Util/XmlArchive.cpp
|
||||||
Util/XmlArchive.h
|
Util/XmlArchive.h
|
||||||
|
|||||||
Reference in New Issue
Block a user