mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
444bfe31c4
* replace CC_NEW/CC_DELETE with ccnew/delete
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#include "core/geometry/Triangle.h"
|
|
#include "base/memory/Memory.h"
|
|
|
|
namespace cc {
|
|
namespace geometry {
|
|
|
|
Triangle *Triangle::create(float ax, float ay, float az,
|
|
float bx, float by, float bz,
|
|
float cx, float cy, float cz) {
|
|
return ccnew Triangle(ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
}
|
|
|
|
auto Triangle::clone(const Triangle &t) -> Triangle * {
|
|
return ccnew Triangle(
|
|
t.a.x, t.a.y, t.a.z,
|
|
t.b.x, t.b.y, t.b.z,
|
|
t.c.x, t.c.y, t.c.z);
|
|
}
|
|
|
|
auto Triangle::copy(Triangle *out, const Triangle &t) -> Triangle * {
|
|
out->a = t.a;
|
|
out->b = t.b;
|
|
out->c = t.c;
|
|
return out;
|
|
}
|
|
|
|
auto Triangle::fromPoints(Triangle *out, const Vec3 &a,
|
|
const Vec3 &b,
|
|
const Vec3 &c) -> Triangle * {
|
|
out->a = a;
|
|
out->b = b;
|
|
out->c = c;
|
|
return out;
|
|
}
|
|
|
|
auto Triangle::set(Triangle *out,
|
|
float ax, float ay, float az,
|
|
float bx, float by, float bz,
|
|
float cx, float cy, float cz) -> Triangle * {
|
|
out->a.x = ax;
|
|
out->a.y = ay;
|
|
out->a.z = az;
|
|
|
|
out->b.x = bx;
|
|
out->b.y = by;
|
|
out->b.z = bz;
|
|
|
|
out->c.x = cx;
|
|
out->c.y = cy;
|
|
out->c.z = cz;
|
|
|
|
return out;
|
|
}
|
|
|
|
Triangle::Triangle(float ax, float ay, float az,
|
|
float bx, float by, float bz,
|
|
float cx, float cy, float cz) {
|
|
setType(ShapeEnum::SHAPE_TRIANGLE);
|
|
a = {ax, ay, az};
|
|
b = {bx, by, bz};
|
|
c = {cx, cy, cz};
|
|
}
|
|
} // namespace geometry
|
|
} // namespace cc
|