CameraMatrix: Pre-allocate Vector in get_projection_planes().
This commit is contained in:
parent
189662e5bd
commit
8a9c9a67ef
2 changed files with 14 additions and 11 deletions
|
@ -346,6 +346,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Vector<Plane> planes;
|
Vector<Plane> planes;
|
||||||
|
planes.resize(6);
|
||||||
|
|
||||||
const real_t *matrix = (const real_t *)this->matrix;
|
const real_t *matrix = (const real_t *)this->matrix;
|
||||||
|
|
||||||
|
@ -360,7 +361,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[0] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
///////--- Far Plane ---///////
|
///////--- Far Plane ---///////
|
||||||
new_plane = Plane(matrix[3] - matrix[2],
|
new_plane = Plane(matrix[3] - matrix[2],
|
||||||
|
@ -371,7 +372,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[1] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
///////--- Left Plane ---///////
|
///////--- Left Plane ---///////
|
||||||
new_plane = Plane(matrix[3] + matrix[0],
|
new_plane = Plane(matrix[3] + matrix[0],
|
||||||
|
@ -382,7 +383,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[2] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
///////--- Top Plane ---///////
|
///////--- Top Plane ---///////
|
||||||
new_plane = Plane(matrix[3] - matrix[1],
|
new_plane = Plane(matrix[3] - matrix[1],
|
||||||
|
@ -393,7 +394,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[3] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
///////--- Right Plane ---///////
|
///////--- Right Plane ---///////
|
||||||
new_plane = Plane(matrix[3] - matrix[0],
|
new_plane = Plane(matrix[3] - matrix[0],
|
||||||
|
@ -404,7 +405,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[4] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
///////--- Bottom Plane ---///////
|
///////--- Bottom Plane ---///////
|
||||||
new_plane = Plane(matrix[3] + matrix[1],
|
new_plane = Plane(matrix[3] + matrix[1],
|
||||||
|
@ -415,7 +416,7 @@ Vector<Plane> CameraMatrix::get_projection_planes(const Transform3D &p_transform
|
||||||
new_plane.normal = -new_plane.normal;
|
new_plane.normal = -new_plane.normal;
|
||||||
new_plane.normalize();
|
new_plane.normalize();
|
||||||
|
|
||||||
planes.push_back(p_transform.xform(new_plane));
|
planes.write[5] = p_transform.xform(new_plane);
|
||||||
|
|
||||||
return planes;
|
return planes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,11 +331,13 @@ Vector<Vector3> Camera3D::get_near_plane_points() const {
|
||||||
Vector3 endpoints[8];
|
Vector3 endpoints[8];
|
||||||
cm.get_endpoints(Transform3D(), endpoints);
|
cm.get_endpoints(Transform3D(), endpoints);
|
||||||
|
|
||||||
Vector<Vector3> points;
|
Vector<Vector3> points = {
|
||||||
points.push_back(Vector3());
|
Vector3(),
|
||||||
for (int i = 0; i < 4; i++) {
|
endpoints[4],
|
||||||
points.push_back(endpoints[i + 4]);
|
endpoints[5],
|
||||||
}
|
endpoints[6],
|
||||||
|
endpoints[7]
|
||||||
|
};
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue