| 130 | } |
| 131 | |
| 132 | void MorphController::SetObject(ControlledObject* object) |
| 133 | { |
| 134 | // Verify that the object satisfies the preconditions that allow a |
| 135 | // MorphController to be attached to it. |
| 136 | auto visual = dynamic_cast<Visual*>(object); |
| 137 | LogAssert(visual != nullptr, "Object is not of type Visual."); |
| 138 | |
| 139 | auto const& vbuffer = visual->GetVertexBuffer(); |
| 140 | LogAssert(vbuffer->GetNumElements() == mNumVertices, "Mismatch in number of vertices."); |
| 141 | |
| 142 | // The vertex buffer for a Visual controlled by a MorphController must |
| 143 | // have 3-tuple or 4-tuple float-valued position that occurs at the |
| 144 | // beginning (offset 0) of the vertex structure. |
| 145 | VertexFormat vformat = vbuffer->GetFormat(); |
| 146 | int32_t index = vformat.GetIndex(VASemantic::POSITION, 0); |
| 147 | LogAssert(index >= 0, "Vertex format does not have VASemantic::POSITION."); |
| 148 | |
| 149 | uint32_t type = vformat.GetType(index); |
| 150 | LogAssert(type == DF_R32G32B32_FLOAT || type == DF_R32G32B32A32_FLOAT, "Invalid position type."); |
| 151 | |
| 152 | uint32_t offset = vformat.GetOffset(index); |
| 153 | LogAssert(offset == 0, "Position offset must be 0."); |
| 154 | |
| 155 | Controller::SetObject(object); |
| 156 | } |
| 157 | |
| 158 | void MorphController::GetKeyInfo(float ctrlTime, float& normTime, size_t& key0, size_t& key1) |
| 159 | { |
nothing calls this directly
no test coverage detected