add spline (#10684)

* add spline
This commit is contained in:
李吉林
2022-04-11 15:49:20 +08:00
committed by GitHub
parent bff1fbe17d
commit f195f7dd2d
27 changed files with 725 additions and 15 deletions
@@ -34,6 +34,7 @@
#include "base/std/container/array.h"
#include "core/geometry/AABB.h"
#include "core/geometry/Frustum.h"
#include "core/geometry/Spline.h"
#include "math/Mat4.h"
#include "math/Math.h"
#include "profiler/Profiler.h"
@@ -810,6 +811,25 @@ void GeometryRenderer::addBezier(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2,
}
}
void GeometryRenderer::addSpline(const geometry::Spline &spline, gfx::Color color, uint32_t index, float knotSize, uint32_t segments, bool depthTest) {
const auto numPoints = segments + 1;
auto points = spline.getPoints(numPoints, index);
for (auto i = 0U; i < segments; i++) {
addLine(points[i], points[i + 1], color, depthTest);
}
if (knotSize > 0.0F && index == geometry::SPLINE_WHOLE_INDEX) {
const gfx::Color crossColor{1.0F - color.x, 1.0F - color.y, 1.0F - color.z, color.w};
const auto numKnots = spline.getKnotCount();
const auto & knots = spline.getKnots();
for (auto i = 0U; i < numKnots; i++) {
addCross(knots[i], knotSize, crossColor, depthTest);
}
}
}
void GeometryRenderer::addMesh(const Vec3 &center, const ccstd::vector<Vec3> &vertices, gfx::Color color, bool depthTest, bool useTransform, const Mat4 &transform) {
for (auto i = 0U; i < vertices.size(); i += 3) {
Vec3 v0 = center + vertices[i];