本文整理汇总了C++中math::Vector3::ZeroOut方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::ZeroOut方法的具体用法?C++ Vector3::ZeroOut怎么用?C++ Vector3::ZeroOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Vector3
的用法示例。
在下文中一共展示了Vector3::ZeroOut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateMassAndLocalCentroid
void PolyhedronColliderGeometry::UpdateMassAndLocalCentroid(const ResolutionMaterial &material, float &mass, Math::Matrix3 &unitInertiaTensor, Math::Vector3 &localCentroid)
{
auto &verts = mAdjacency.Verts();
auto &edges = mAdjacency.Edges();
auto &faces = mAdjacency.Faces();
const Math::Vector3 &c = mAdjacency.Centroid();
mass = 0.0f;
unitInertiaTensor.ZeroOut();
localCentroid.ZeroOut();
float totalVolume = 0.0f;
for (auto &face : faces)
{
if (!face.active)
continue;
// grab face verts
int e = face.edge;
const Math::Vector3 &v0 = verts[edges[e].vert].position;
e = edges[e].next;
const Math::Vector3 &v1 = verts[edges[e].vert].position;
e = edges[e].next;
const Math::Vector3 &v2 = verts[edges[e].vert].position;
// volume of tetrahedron formed by face & centroid (not divided by 6)
const float tetrahedronVolume = std::fabs((v0 - c).Dot((v1 - c).Cross(v2 - c)));
// accumulate volume
totalVolume += tetrahedronVolume;
// accumulate weighted centroid
const Math::Vector3 tetrahedronCentroid = 0.25f * (c + v0 + v1 + v2);
localCentroid += tetrahedronVolume * tetrahedronCentroid;
}
if (totalVolume == 0)
totalVolume = 1;
localCentroid /= totalVolume;
//mass = material.mDensity * totalVolume / 6.0f;
mass = mParent->Parent().mParent->cphy->mMass * totalVolume / 6.0f;
// compute inertia tensor
for (auto &face : faces)
{
if (!face.active)
continue;
// grab face verts
int e = face.edge;
const Math::Vector3 &v0 = verts[edges[e].vert].position;
e = edges[e].next;
const Math::Vector3 &v1 = verts[edges[e].vert].position;
e = edges[e].next;
const Math::Vector3 &v2 = verts[edges[e].vert].position;
// accumulate inertia tensor
unitInertiaTensor += UnitInertiaTensorTetrahedron(c, v0, v1, v2, localCentroid);
}
}