summaryrefslogtreecommitdiff
path: root/scene/resources/primitive_meshes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/primitive_meshes.cpp')
-rw-r--r--scene/resources/primitive_meshes.cpp136
1 files changed, 68 insertions, 68 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index fa0ded12a1..00fc016ca1 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -40,7 +40,7 @@ void PrimitiveMesh::_update() const {
arr.resize(VS::ARRAY_MAX);
_create_mesh_array(arr);
- PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX];
+ Vector<Vector3> points = arr[VS::ARRAY_VERTEX];
aabb = AABB();
@@ -48,7 +48,7 @@ void PrimitiveMesh::_update() const {
ERR_FAIL_COND(pc == 0);
{
- PoolVector<Vector3>::Read r = points.read();
+ const Vector3 *r = points.ptr();
for (int i = 0; i < pc; i++) {
if (i == 0)
aabb.position = r[i];
@@ -57,16 +57,16 @@ void PrimitiveMesh::_update() const {
}
}
- PoolVector<int> indices = arr[VS::ARRAY_INDEX];
+ Vector<int> indices = arr[VS::ARRAY_INDEX];
if (flip_faces) {
- PoolVector<Vector3> normals = arr[VS::ARRAY_NORMAL];
+ Vector<Vector3> normals = arr[VS::ARRAY_NORMAL];
if (normals.size() && indices.size()) {
{
int nc = normals.size();
- PoolVector<Vector3>::Write w = normals.write();
+ Vector3 *w = normals.ptrw();
for (int i = 0; i < nc; i++) {
w[i] = -w[i];
}
@@ -74,7 +74,7 @@ void PrimitiveMesh::_update() const {
{
int ic = indices.size();
- PoolVector<int>::Write w = indices.write();
+ int *w = indices.ptrw();
for (int i = 0; i < ic; i += 3) {
SWAP(w[i + 0], w[i + 1]);
}
@@ -282,11 +282,11 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
// note, this has been aligned with our collision shape but I've left the descriptions as top/middle/bottom
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -303,19 +303,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
v /= (rings + 1);
w = sin(0.5 * Math_PI * v);
- z = radius * cos(0.5 * Math_PI * v);
+ y = radius * cos(0.5 * Math_PI * v);
for (i = 0; i <= radial_segments; i++) {
u = i;
u /= radial_segments;
- x = sin(u * (Math_PI * 2.0));
- y = -cos(u * (Math_PI * 2.0));
+ x = -sin(u * (Math_PI * 2.0));
+ z = cos(u * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius * w, y * radius * w, z);
- points.push_back(p + Vector3(0.0, 0.0, 0.5 * mid_height));
+ Vector3 p = Vector3(x * radius * w, y, -z * radius * w);
+ points.push_back(p + Vector3(0.0, 0.5 * mid_height, 0.0));
normals.push_back(p.normalized());
- ADD_TANGENT(-y, x, 0.0, 1.0)
+ ADD_TANGENT(z, 0.0, x, 1.0)
uvs.push_back(Vector2(u, v * onethird));
point++;
@@ -341,20 +341,20 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
v = j;
v /= (rings + 1);
- z = mid_height * v;
- z = (mid_height * 0.5) - z;
+ y = mid_height * v;
+ y = (mid_height * 0.5) - y;
for (i = 0; i <= radial_segments; i++) {
u = i;
u /= radial_segments;
- x = sin(u * (Math_PI * 2.0));
- y = -cos(u * (Math_PI * 2.0));
+ x = -sin(u * (Math_PI * 2.0));
+ z = cos(u * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius, y * radius, z);
+ Vector3 p = Vector3(x * radius, y, -z * radius);
points.push_back(p);
- normals.push_back(Vector3(x, y, 0.0));
- ADD_TANGENT(-y, x, 0.0, 1.0)
+ normals.push_back(Vector3(x, 0.0, -z));
+ ADD_TANGENT(z, 0.0, x, 1.0)
uvs.push_back(Vector2(u, onethird + (v * onethird)));
point++;
@@ -382,19 +382,19 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const {
v /= (rings + 1);
v += 1.0;
w = sin(0.5 * Math_PI * v);
- z = radius * cos(0.5 * Math_PI * v);
+ y = radius * cos(0.5 * Math_PI * v);
for (i = 0; i <= radial_segments; i++) {
float u2 = i;
u2 /= radial_segments;
- x = sin(u2 * (Math_PI * 2.0));
- y = -cos(u2 * (Math_PI * 2.0));
+ x = -sin(u2 * (Math_PI * 2.0));
+ z = cos(u2 * (Math_PI * 2.0));
- Vector3 p = Vector3(x * radius * w, y * radius * w, z);
- points.push_back(p + Vector3(0.0, 0.0, -0.5 * mid_height));
+ Vector3 p = Vector3(x * radius * w, y, -z * radius * w);
+ points.push_back(p + Vector3(0.0, -0.5 * mid_height, 0.0));
normals.push_back(p.normalized());
- ADD_TANGENT(-y, x, 0.0, 1.0)
+ ADD_TANGENT(z, 0.0, x, 1.0)
uvs.push_back(Vector2(u2, twothirds + ((v - 1.0) * onethird)));
point++;
@@ -431,8 +431,8 @@ void CapsuleMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CapsuleMesh::set_rings);
ClassDB::bind_method(D_METHOD("get_rings"), &CapsuleMesh::get_rings);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_radius", "get_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "mid_height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_mid_height", "get_mid_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mid_height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_mid_height", "get_mid_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_rings", "get_rings");
}
@@ -495,11 +495,11 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const {
// set our bounding box
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -746,11 +746,11 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const {
int i, j, prevrow, thisrow, point;
float x, y, z, u, v, radius;
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -891,9 +891,9 @@ void CylinderMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rings", "rings"), &CylinderMesh::set_rings);
ClassDB::bind_method(D_METHOD("get_rings"), &CylinderMesh::get_rings);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "top_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_top_radius", "get_top_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "bottom_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_bottom_radius", "get_bottom_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "top_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_top_radius", "get_top_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bottom_radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_bottom_radius", "get_bottom_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_rings", "get_rings");
}
@@ -962,11 +962,11 @@ void PlaneMesh::_create_mesh_array(Array &p_arr) const {
Size2 start_pos = size * -0.5;
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -1079,11 +1079,11 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const {
// set our bounding box
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -1291,7 +1291,7 @@ void PrismMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subdivide_depth", "segments"), &PrismMesh::set_subdivide_depth);
ClassDB::bind_method(D_METHOD("get_subdivide_depth"), &PrismMesh::get_subdivide_depth);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "left_to_right", PROPERTY_HINT_RANGE, "-2.0,2.0,0.1"), "set_left_to_right", "get_left_to_right");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "left_to_right", PROPERTY_HINT_RANGE, "-2.0,2.0,0.1"), "set_left_to_right", "get_left_to_right");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_width", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_width", "get_subdivide_width");
ADD_PROPERTY(PropertyInfo(Variant::INT, "subdivide_height", PROPERTY_HINT_RANGE, "0,100,1,or_greater"), "set_subdivide_height", "get_subdivide_height");
@@ -1357,10 +1357,10 @@ PrismMesh::PrismMesh() {
*/
void QuadMesh::_create_mesh_array(Array &p_arr) const {
- PoolVector<Vector3> faces;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
+ Vector<Vector3> faces;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
faces.resize(6);
normals.resize(6);
@@ -1437,11 +1437,11 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const {
// set our bounding box
- PoolVector<Vector3> points;
- PoolVector<Vector3> normals;
- PoolVector<float> tangents;
- PoolVector<Vector2> uvs;
- PoolVector<int> indices;
+ Vector<Vector3> points;
+ Vector<Vector3> normals;
+ Vector<float> tangents;
+ Vector<Vector2> uvs;
+ Vector<int> indices;
point = 0;
#define ADD_TANGENT(m_x, m_y, m_z, m_d) \
@@ -1515,8 +1515,8 @@ void SphereMesh::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_is_hemisphere", "is_hemisphere"), &SphereMesh::set_is_hemisphere);
ClassDB::bind_method(D_METHOD("get_is_hemisphere"), &SphereMesh::get_is_hemisphere);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_radius", "get_radius");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radius", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_radius", "get_radius");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_RANGE, "0.001,100.0,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_radial_segments", "get_radial_segments");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1,or_greater"), "set_rings", "get_rings");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_hemisphere"), "set_is_hemisphere", "get_is_hemisphere");
@@ -1581,7 +1581,7 @@ SphereMesh::SphereMesh() {
*/
void PointMesh::_create_mesh_array(Array &p_arr) const {
- PoolVector<Vector3> faces;
+ Vector<Vector3> faces;
faces.resize(1);
faces.set(0, Vector3(0.0, 0.0, 0.0));