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

Method UpdatePointMotion

GTE/Graphics/PointController.cpp:112–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void PointController::UpdatePointMotion(float ctrlTime)
113{
114 auto visual = static_cast<Visual*>(mObject);
115 auto const& vbuffer = visual->GetVertexBuffer();
116 VertexFormat vformat = vbuffer->GetFormat();
117 uint32_t numVertices = vbuffer->GetNumElements();
118 char* vertices = vbuffer->GetData();
119 size_t vertexSize = static_cast<size_t>(vformat.GetVertexSize());
120
121 for (uint32_t i = 0; i < numVertices; ++i)
122 {
123 Vector3<float>& position = *reinterpret_cast<Vector3<float>*>(vertices);
124 float distance = ctrlTime * mPointLinearSpeed[i];
125 Vector3<float> deltaTrn = distance * mPointLinearAxis[i];
126 position += deltaTrn;
127 vertices += vertexSize;
128 }
129
130 int32_t index = vformat.GetIndex(VASemantic::NORMAL, 0);
131 if (index >= 0)
132 {
133 uint32_t offset = vformat.GetOffset(index);
134 vertices = vbuffer->GetData() + offset;
135 for (uint32_t i = 0; i < numVertices; ++i)
136 {
137 Vector3<float>& normal = *reinterpret_cast<Vector3<float>*>(vertices);
138 Normalize(normal);
139 float angle = ctrlTime * mPointAngularSpeed[i];
140 Matrix3x3<float> deltaRot =
141 Rotation<3, float>(AxisAngle<3, float>(mPointAngularAxis[i], angle));
142 normal = deltaRot * normal;
143 vertices += vertexSize;
144 }
145 }
146
147 visual->UpdateModelBound();
148 visual->UpdateModelNormals();
149 mPostUpdate(vbuffer);
150}
151
152

Callers

nothing calls this directly

Calls 10

GetVertexSizeMethod · 0.80
UpdateModelBoundMethod · 0.80
UpdateModelNormalsMethod · 0.80
NormalizeFunction · 0.50
GetVertexBufferMethod · 0.45
GetFormatMethod · 0.45
GetNumElementsMethod · 0.45
GetDataMethod · 0.45
GetIndexMethod · 0.45
GetOffsetMethod · 0.45

Tested by

no test coverage detected