[DiscordArchive] stupid question, how on earth do I get the number of elements in a const_iterator?
[DiscordArchive] stupid question, how on earth do I get the number of elements in a const_iterator?
Archived author: stoneharry • Posted: 2024-06-24T17:45:38.708000+00:00
Original source
```c++
struct GModelRayCallback
{
GModelRayCallback(std::vector<MeshTriangle> const& tris, const std::vector<Vector3> &vert):
vertices(vert.begin()), numVertices(vert.size()), triangles(tris.begin()), hit(false) { }
bool operator()(G3D::Ray const& ray, uint32 entry, float& distance, bool /*pStopAtFirstHit*/)
{
hit = IntersectTriangle(triangles[entry], vertices, numVertices, ray, distance) || hit;
return hit;
}
std::vector<Vector3>::const_iterator vertices;
std::vector<MeshTriangle>::const_iterator triangles;
bool hit;
uint32 numVertices;
};
```
should be fine
Archived author: jackpoz • Posted: 2024-06-24T17:49:53.049000+00:00
Original source
just do the validation in GModelRayCallback
Archived author: jackpoz • Posted: 2024-06-24T17:52:15.484000+00:00
Original source
oh, right, it's ctor and operator(), so yeah, what you said