-------------------------------------------------------------------------------- Description: Fill the per-object data. First the world matrix of the parent-ship, then up to x matrices for each single turret (for deformation in the vertex shader). Pass both pose and world matrix to vertex shader, so we can pose the mesh in the shader and then "cut-off" (clip) all z < 0 pixels to avoid intersecting
| 2273 | // EveTurretSetPerObjectData, TriRenderBatchAccumulator |
| 2274 | // -------------------------------------------------------------------------------- |
| 2275 | Tr2PerObjectData* EveTurretSet::GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) |
| 2276 | { |
| 2277 | if( !m_geometryResource ) |
| 2278 | { |
| 2279 | return NULL; |
| 2280 | } |
| 2281 | |
| 2282 | if( !m_geometryResource->IsGood() ) |
| 2283 | { |
| 2284 | return NULL; |
| 2285 | } |
| 2286 | |
| 2287 | if( m_geometryResource->GetMeshCount() < 1 ) |
| 2288 | { |
| 2289 | return NULL; |
| 2290 | } |
| 2291 | |
| 2292 | // allocate only once |
| 2293 | auto perObjectData = accumulator->Allocate<EveTurretSetPerObjectData>(); |
| 2294 | if( !perObjectData ) |
| 2295 | { |
| 2296 | return NULL; |
| 2297 | } |
| 2298 | |
| 2299 | |
| 2300 | if( IsUsingCMF( m_geometryResource ) ) |
| 2301 | { |
| 2302 | Vector3 scale, translation; |
| 2303 | |
| 2304 | // tell "parent"-ship matrix |
| 2305 | perObjectData->m_vsData.m_shipMatrix = Transpose( m_parentData.transform ); |
| 2306 | perObjectData->m_vsData.m_prevShipMatrix = Transpose( m_shipTransformPrev ); |
| 2307 | |
| 2308 | // put together clip-data, so we can have a clip plane to cut off the turrets base to avoid intersections |
| 2309 | perObjectData->m_vsData.m_baseCutoffData = Vector4( m_bottomClipHeight, 0.f, 0.f, 0.f ); |
| 2310 | |
| 2311 | // fill with data |
| 2312 | if( !m_singleTurrets.empty() ) |
| 2313 | { |
| 2314 | unsigned int defaultBonesPerTurret = 3; |
| 2315 | // to-bone-index-mapping for the shader (is the same for all turrets of the set) |
| 2316 | unsigned int boneCount = m_skeletonBoneIndices.size() ? (unsigned int)m_skeletonBoneIndices.size() : defaultBonesPerTurret; |
| 2317 | |
| 2318 | // Index of the bone in the big translation and rotation |
| 2319 | unsigned int turretIndex = 0; |
| 2320 | uint32_t boneIndex = 0; |
| 2321 | |
| 2322 | // put all single turret's positions and rotations in the array |
| 2323 | for( const auto& turret : m_singleTurrets ) |
| 2324 | { |
| 2325 | if( turret.visible ) |
| 2326 | { |
| 2327 | // actual turret position and rotation |
| 2328 | if( turret.valid ) |
| 2329 | { |
| 2330 | perObjectData->m_vsData.m_turretRotation[turretIndex] = turret.localQuaternion; |
| 2331 | perObjectData->m_vsData.m_turretTranslation[turretIndex] = turret.localPosition; |
| 2332 | } |
nothing calls this directly
no test coverage detected