Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_float_to_int.cc
- This file was added.
| /* | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| */ | |||||
| #include "BKE_material.h" | |||||
| #include "BKE_mesh.h" | |||||
| #include "BKE_mesh_runtime.h" | |||||
| #include "BKE_pointcloud.h" | |||||
| #include "BKE_spline.hh" | |||||
| #include "DNA_mesh_types.h" | |||||
| #include "DNA_meshdata_types.h" | |||||
| #include "NOD_type_conversions.hh" | |||||
| #include "node_geometry_util.hh" | |||||
| using blender::fn::GVArray_For_GSpan; | |||||
| static bNodeSocketTemplate geo_node_float_to_int_in[] = { | |||||
| {SOCK_FLOAT, N_("Float"), 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, PROP_FACTOR}, | |||||
| {-1, ""}, | |||||
| }; | |||||
| static bNodeSocketTemplate geo_node_float_to_int_out[] = { | |||||
| {SOCK_INT, N_("Integer"), 1, 0, 0, 0, 0, 6}, | |||||
| {-1, ""}, | |||||
| }; | |||||
| namespace blender::nodes { | |||||
| static void geo_node_float_to_int_exec(GeoNodeExecParams params) | |||||
| { | |||||
| float input_value = params.extract_input<float>("Float"); | |||||
HooglyBoogly: Comments should start with a `/*`, and end with a period. | |||||
| /* Do a simple forced cast to the nearest integer */ | |||||
| int rounded_value = (int)input_value; | |||||
| params.set_output("Integer", rounded_value); | |||||
| } | |||||
| } // namespace blender::nodes | |||||
| void register_node_type_geo_float_to_int() | |||||
| { | |||||
| static bNodeType ntype; | |||||
Not Done Inline Actionsroundingmode -> rounding_mode HooglyBoogly: `roundingmode` -> `rounding_mode` | |||||
| geo_node_type_base(&ntype, GEO_NODE_FLOAT_TO_INT, "Float to Int", NODE_CLASS_GEOMETRY, 0); | |||||
| node_type_socket_templates(&ntype, geo_node_float_to_int_in, geo_node_float_to_int_out); | |||||
| ntype.geometry_node_execute = blender::nodes::geo_node_float_to_int_exec; | |||||
| nodeRegisterType(&ntype); | |||||
| } | |||||
Comments should start with a /*, and end with a period.