MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / GenerateParticles

Method GenerateParticles

GTE/Graphics/Particles.cpp:95–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void Particles::GenerateParticles(std::shared_ptr<Camera> const& camera)
96{
97 // Get access to the positions.
98 VertexFormat vformat = mVBuffer->GetFormat();
99 uint32_t vertexSize = vformat.GetVertexSize();
100 char* vertices = mVBuffer->GetData();
101
102 // Get camera axis directions in model space of particles.
103 Matrix4x4<float> inverse = worldTransform.GetHInverse();
104 Vector4<float> UpR = inverse * (camera->GetUVector() + camera->GetRVector());
105 Vector4<float> UmR = inverse * (camera->GetUVector() - camera->GetRVector());
106
107 // Generate quadrilaterals as pairs of triangles.
108 for (uint32_t i = 0; i < mNumActive; ++i)
109 {
110 Vector4<float> posSize = mPositionSize[i];
111 Vector3<float> position{ posSize[0], posSize[1], posSize[2] };
112 float trueSize = mSizeAdjust * posSize[3];
113 Vector3<float> scaledUpR = HProject(trueSize * UpR);
114 Vector3<float> scaledUmR = HProject(trueSize * UmR);
115
116 Vector3<float>& pos0 = *reinterpret_cast<Vector3<float>*>(vertices);
117 pos0 = position - scaledUpR;
118 vertices += vertexSize;
119
120 Vector3<float>& pos1 = *reinterpret_cast<Vector3<float>*>(vertices);
121 pos1 = position - scaledUmR;
122 vertices += vertexSize;
123
124 Vector3<float>& pos2 = *reinterpret_cast<Vector3<float>*>(vertices);
125 pos2 = position + scaledUpR;
126 vertices += vertexSize;
127
128 Vector3<float>& pos3 = *reinterpret_cast<Vector3<float>*>(vertices);
129 pos3 = position + scaledUmR;
130 vertices += vertexSize;
131 }
132
133 UpdateModelBound();
134}
135
136uint32_t Particles::IsValid(VertexFormat const& vformat) const
137{

Callers 2

UpdatePointMotionMethod · 0.80
UpdatePointMotionMethod · 0.80

Calls 4

GetVertexSizeMethod · 0.80
HProjectFunction · 0.50
GetFormatMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected