| 110 | } |
| 111 | |
| 112 | void 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 |
nothing calls this directly
no test coverage detected