| 134 | } |
| 135 | |
| 136 | uint32_t Particles::IsValid(VertexFormat const& vformat) const |
| 137 | { |
| 138 | // Validate the vertex position. |
| 139 | int32_t index = vformat.GetIndex(VASemantic::POSITION, 0); |
| 140 | if (index < 0) |
| 141 | { |
| 142 | #if defined(GTE_THROW_ON_PARTICLES_INVALID) |
| 143 | LogError("Vertex format does not have VASemantic::POSITION."); |
| 144 | #else |
| 145 | return std::numeric_limits<uint32_t>::max(); |
| 146 | #endif |
| 147 | } |
| 148 | |
| 149 | uint32_t posType = vformat.GetType(index); |
| 150 | if (posType != DF_R32G32B32_FLOAT && posType != DF_R32G32B32A32_FLOAT) |
| 151 | { |
| 152 | #if defined(GTE_THROW_ON_PARTICLES_INVALID) |
| 153 | LogError("Invalid position type."); |
| 154 | #else |
| 155 | return std::numeric_limits<uint32_t>::max(); |
| 156 | #endif |
| 157 | } |
| 158 | |
| 159 | uint32_t offset = vformat.GetOffset(index); |
| 160 | if (offset != 0) |
| 161 | { |
| 162 | #if defined(GTE_THROW_ON_PARTICLES_INVALID) |
| 163 | LogError("Position offset must be 0."); |
| 164 | #else |
| 165 | return std::numeric_limits<uint32_t>::max(); |
| 166 | #endif |
| 167 | } |
| 168 | |
| 169 | // Validate the vertex texture coordinate that is used for drawing the |
| 170 | // billboards. |
| 171 | index = vformat.GetIndex(VASemantic::TEXCOORD, 0); |
| 172 | if (index < 0) |
| 173 | { |
| 174 | #if defined(GTE_THROW_ON_PARTICLES_INVALID) |
| 175 | LogError("Vertex format does not have VASemantic::TEXCOORD."); |
| 176 | #else |
| 177 | return std::numeric_limits<uint32_t>::max(); |
| 178 | #endif |
| 179 | } |
| 180 | |
| 181 | uint32_t texType = vformat.GetType(index); |
| 182 | if (texType != DF_R32G32_FLOAT) |
| 183 | { |
| 184 | #if defined(GTE_THROW_ON_PARTICLES_INVALID) |
| 185 | LogError("Invalid texture coordinate type."); |
| 186 | #else |
| 187 | return std::numeric_limits<uint32_t>::max(); |
| 188 | #endif |
| 189 | } |
| 190 | |
| 191 | uint32_t texOffset = (posType == DF_R32G32B32_FLOAT ? 3 * sizeof(float) : 4 * sizeof(float)); |
| 192 | offset = vformat.GetOffset(index); |
| 193 | if (offset != texOffset) |
no test coverage detected