gwnavruntime/math/triangle3i.h Source File

triangle3i.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 #pragma once
8 
10 
11 namespace Kaim
12 {
13 
16 {
17  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
18 
19 public:
20  Triangle3i() {}
21  Triangle3i(const Vec3i& A_, const Vec3i& B_, const Vec3i& C_) : A(A_), B(B_), C(C_) {}
22 
23  void Set(const Vec3i& A_, const Vec3i& B_, const Vec3i& C_) { A = A_; B = B_; C = C_; }
24 
25  Vec3i& operator[](KyInt32 i) { return (&A)[i]; }
26  const Vec3i& operator[](KyInt32 i) const { return (&A)[i]; }
27 
30  KyUInt32 IsInside2d(const Vec2i& M) const { return M.IsInsideTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
31 
34  bool IsInside2d_NoFlat(const Vec2i& M) const { return M.IsInsideNotColinearTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
35 
37  bool IsStrictlyInside2d(const Vec2i& M) const { return M.IsStrictlyInsideTriangle(Vec2i(A.x, A.y), Vec2i(B.x, B.y), Vec2i(C.x, C.y)); }
38 
39 public:
40  Vec3i A;
41  Vec3i B;
42  Vec3i C;
43 };
44 
45 inline void SwapEndianness(Endianness::Target e, Triangle3i& self)
46 {
47  SwapEndianness(e, self.A);
48  SwapEndianness(e, self.B);
49  SwapEndianness(e, self.C);
50 }
51 
52 
53 }
54 
55 
56 
3d vector using 32bits integer
Definition: vec3i.h:15
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
bool IsInside2d_NoFlat(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie inside the (X,Y) extents of the tria...
Definition: triangle3i.h:34
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
KyUInt32 IsInside2d(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie inside the (X,Y) extents of the tria...
Definition: triangle3i.h:30
2d vector using KyInt32
Definition: vec2i.h:18
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
3d triangle of 32bits integer points
Definition: triangle3i.h:15
bool IsStrictlyInside2d(const Vec2i &M) const
Returns true if the (X,Y) coordinates of the specified point lie strictly inside the (X...
Definition: triangle3i.h:37