1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Use Vector3 instead of 3 floats for CSGBox3D dimensions

This commit is contained in:
Marcel Admiraal
2020-12-07 18:54:12 +00:00
parent 43c9106806
commit 4da4feed18
5 changed files with 32 additions and 119 deletions

View File

@@ -1125,7 +1125,7 @@ CSGBrush *CSGBox3D::_build_brush() {
int face = 0;
Vector3 vertex_mul(width * 0.5, height * 0.5, depth * 0.5);
Vector3 vertex_mul = size / 2;
{
for (int i = 0; i < 6; i++) {
@@ -1194,55 +1194,25 @@ CSGBrush *CSGBox3D::_build_brush() {
}
void CSGBox3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_width", "width"), &CSGBox3D::set_width);
ClassDB::bind_method(D_METHOD("get_width"), &CSGBox3D::get_width);
ClassDB::bind_method(D_METHOD("set_height", "height"), &CSGBox3D::set_height);
ClassDB::bind_method(D_METHOD("get_height"), &CSGBox3D::get_height);
ClassDB::bind_method(D_METHOD("set_depth", "depth"), &CSGBox3D::set_depth);
ClassDB::bind_method(D_METHOD("get_depth"), &CSGBox3D::get_depth);
ClassDB::bind_method(D_METHOD("set_size", "size"), &CSGBox3D::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &CSGBox3D::get_size);
ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGBox3D::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &CSGBox3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "size"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material");
}
void CSGBox3D::set_width(const float p_width) {
width = p_width;
void CSGBox3D::set_size(const Vector3 &p_size) {
size = p_size;
_make_dirty();
update_gizmo();
_change_notify("width");
_change_notify("size");
}
float CSGBox3D::get_width() const {
return width;
}
void CSGBox3D::set_height(const float p_height) {
height = p_height;
_make_dirty();
update_gizmo();
_change_notify("height");
}
float CSGBox3D::get_height() const {
return height;
}
void CSGBox3D::set_depth(const float p_depth) {
depth = p_depth;
_make_dirty();
update_gizmo();
_change_notify("depth");
}
float CSGBox3D::get_depth() const {
return depth;
Vector3 CSGBox3D::get_size() const {
return size;
}
void CSGBox3D::set_material(const Ref<Material> &p_material) {
@@ -1255,13 +1225,6 @@ Ref<Material> CSGBox3D::get_material() const {
return material;
}
CSGBox3D::CSGBox3D() {
// defaults
width = 2.0;
height = 2.0;
depth = 2.0;
}
///////////////
CSGBrush *CSGCylinder3D::_build_brush() {