Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Triangle.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
11{
12public:
14
16 Triangle() = default;
17 Triangle(const Float3 &inV1, const Float3 &inV2, const Float3 &inV3) : mV { inV1, inV2, inV3 } { }
18 Triangle(const Float3 &inV1, const Float3 &inV2, const Float3 &inV3, uint32 inMaterialIndex) : Triangle(inV1, inV2, inV3) { mMaterialIndex = inMaterialIndex; }
19 Triangle(Vec3Arg inV1, Vec3Arg inV2, Vec3Arg inV3) { inV1.StoreFloat3(&mV[0]); inV2.StoreFloat3(&mV[1]); inV3.StoreFloat3(&mV[2]); }
20
23 {
24 return (Vec3::sLoadFloat3Unsafe(mV[0]) + Vec3::sLoadFloat3Unsafe(mV[1]) + Vec3::sLoadFloat3Unsafe(mV[2])) * (1.0f / 3.0f);
25 }
26
30};
31
33
#define JPH_NAMESPACE_END
Definition: Core.h:367
std::uint32_t uint32
Definition: Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
Array< Triangle > TriangleList
Definition: Triangle.h:32
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition: Float3.h:13
A simple triangle and its material.
Definition: Triangle.h:11
Vec3 GetCentroid() const
Get center of triangle.
Definition: Triangle.h:22
uint32 mMaterialIndex
Follows mV[3] so that we can read mV as 4 vectors.
Definition: Triangle.h:29
Triangle(const Float3 &inV1, const Float3 &inV2, const Float3 &inV3)
Definition: Triangle.h:17
JPH_OVERRIDE_NEW_DELETE Triangle()=default
Constructor.
Triangle(Vec3Arg inV1, Vec3Arg inV2, Vec3Arg inV3)
Definition: Triangle.h:19
Float3 mV[3]
Vertices.
Definition: Triangle.h:28
Triangle(const Float3 &inV1, const Float3 &inV2, const Float3 &inV3, uint32 inMaterialIndex)
Definition: Triangle.h:18
Definition: Vec3.h:16
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store 3 floats to memory.
Definition: Vec3.inl:757
static JPH_INLINE Vec3 sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (reads 32 bits extra which it doesn't use)
Definition: Vec3.inl:134