optimize primitives bounding box points
This commit is contained in:
@@ -56,17 +56,15 @@ namespace math
|
||||
|
||||
std::vector<glm::vec3> box_points(glm::vec3 const& box_min, glm::vec3 const& box_max)
|
||||
{
|
||||
std::vector<glm::vec3> points;
|
||||
|
||||
points.emplace_back(box_max.x, box_max.y, box_max.z);
|
||||
points.emplace_back(box_max.x, box_max.y, box_min.z);
|
||||
points.emplace_back(box_max.x, box_min.y, box_max.z);
|
||||
points.emplace_back(box_max.x, box_min.y, box_min.z);
|
||||
points.emplace_back(box_min.x, box_max.y, box_max.z);
|
||||
points.emplace_back(box_min.x, box_max.y, box_min.z);
|
||||
points.emplace_back(box_min.x, box_min.y, box_max.z);
|
||||
points.emplace_back(box_min.x, box_min.y, box_min.z);
|
||||
|
||||
return points;
|
||||
return std::vector<glm::vec3> {
|
||||
glm::vec3(box_max.x, box_max.y, box_max.z),
|
||||
glm::vec3(box_max.x, box_max.y, box_min.z),
|
||||
glm::vec3(box_max.x, box_min.y, box_max.z),
|
||||
glm::vec3(box_max.x, box_min.y, box_min.z),
|
||||
glm::vec3(box_min.x, box_max.y, box_max.z),
|
||||
glm::vec3(box_min.x, box_max.y, box_min.z),
|
||||
glm::vec3(box_min.x, box_min.y, box_max.z),
|
||||
glm::vec3(box_min.x, box_min.y, box_min.z)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,18 +35,19 @@ void WireBox::draw ( glm::mat4x4 const& model_view
|
||||
|
||||
auto points = math::box_points(min_point, max_point);
|
||||
|
||||
auto glmPoints = std::vector<glm::vec3>();
|
||||
/*auto glmPoints = std::vector<glm::vec3>();
|
||||
|
||||
for(auto const point : points)
|
||||
|
||||
for(auto const &point : points)
|
||||
{
|
||||
glmPoints.push_back(glm::vec3(point.x, point.y, point.z));
|
||||
}
|
||||
}*/
|
||||
|
||||
wire_box_shader.uniform("model_view", model_view);
|
||||
wire_box_shader.uniform("projection", projection);
|
||||
wire_box_shader.uniform("transform", transform);
|
||||
wire_box_shader.uniform("color", color);
|
||||
wire_box_shader.uniform("pointPositions", glmPoints);
|
||||
wire_box_shader.uniform("pointPositions", points);
|
||||
|
||||
OpenGL::Scoped::bool_setter<GL_LINE_SMOOTH, GL_TRUE> const line_smooth;
|
||||
gl.hint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
|
||||
Reference in New Issue
Block a user