Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/volume_render.cc
| Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | static blender::Vector<openvdb::CoordBBox> get_bounding_boxes(VolumeGridType grid_type, | ||||
| return BKE_volume_grid_type_operation(grid_type, op); | return BKE_volume_grid_type_operation(grid_type, op); | ||||
| } | } | ||||
| static void boxes_to_center_points(blender::Span<openvdb::CoordBBox> boxes, | static void boxes_to_center_points(blender::Span<openvdb::CoordBBox> boxes, | ||||
| const openvdb::math::Transform &transform, | const openvdb::math::Transform &transform, | ||||
| blender::MutableSpan<blender::float3> r_verts) | blender::MutableSpan<blender::float3> r_verts) | ||||
| { | { | ||||
| BLI_assert(boxes.size() == r_verts.size()); | BLI_assert(boxes.size() == r_verts.size()); | ||||
| for (const int i : boxes.index_range()) { | for (const int i : blender::iter_indices(boxes)) { | ||||
| openvdb::Vec3d center = transform.indexToWorld(boxes[i].getCenter()); | openvdb::Vec3d center = transform.indexToWorld(boxes[i].getCenter()); | ||||
| r_verts[i] = blender::float3(center[0], center[1], center[2]); | r_verts[i] = blender::float3(center[0], center[1], center[2]); | ||||
| } | } | ||||
| } | } | ||||
| static void boxes_to_corner_points(blender::Span<openvdb::CoordBBox> boxes, | static void boxes_to_corner_points(blender::Span<openvdb::CoordBBox> boxes, | ||||
| const openvdb::math::Transform &transform, | const openvdb::math::Transform &transform, | ||||
| blender::MutableSpan<blender::float3> r_verts) | blender::MutableSpan<blender::float3> r_verts) | ||||
| { | { | ||||
| BLI_assert(boxes.size() * 8 == r_verts.size()); | BLI_assert(boxes.size() * 8 == r_verts.size()); | ||||
| for (const int i : boxes.index_range()) { | for (const int i : blender::iter_indices(boxes)) { | ||||
| const openvdb::CoordBBox &box = boxes[i]; | const openvdb::CoordBBox &box = boxes[i]; | ||||
| /* The ordering of the corner points is lexicographic. */ | /* The ordering of the corner points is lexicographic. */ | ||||
| std::array<openvdb::Coord, 8> corners; | std::array<openvdb::Coord, 8> corners; | ||||
| box.getCornerPoints(corners.data()); | box.getCornerPoints(corners.data()); | ||||
| for (int j = 0; j < 8; j++) { | for (int j = 0; j < 8; j++) { | ||||
| openvdb::Coord corner_i = corners[j]; | openvdb::Coord corner_i = corners[j]; | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | static void grow_triangles(blender::MutableSpan<blender::float3> verts, | ||||
| * This formula simply tries increases the length of all edges. */ | * This formula simply tries increases the length of all edges. */ | ||||
| blender::Array<blender::float3> offsets(verts.size(), {0, 0, 0}); | blender::Array<blender::float3> offsets(verts.size(), {0, 0, 0}); | ||||
| for (const std::array<int, 3> &tri : tris) { | for (const std::array<int, 3> &tri : tris) { | ||||
| offsets[tri[0]] += factor * (2 * verts[tri[0]] - verts[tri[1]] - verts[tri[2]]); | offsets[tri[0]] += factor * (2 * verts[tri[0]] - verts[tri[1]] - verts[tri[2]]); | ||||
| offsets[tri[1]] += factor * (2 * verts[tri[1]] - verts[tri[0]] - verts[tri[2]]); | offsets[tri[1]] += factor * (2 * verts[tri[1]] - verts[tri[0]] - verts[tri[2]]); | ||||
| offsets[tri[2]] += factor * (2 * verts[tri[2]] - verts[tri[0]] - verts[tri[1]]); | offsets[tri[2]] += factor * (2 * verts[tri[2]] - verts[tri[0]] - verts[tri[1]]); | ||||
| } | } | ||||
| /* Apply the computed offsets. */ | /* Apply the computed offsets. */ | ||||
| for (const int i : verts.index_range()) { | for (const int i : blender::iter_indices(verts)) { | ||||
| verts[i] += offsets[i]; | verts[i] += offsets[i]; | ||||
| } | } | ||||
| } | } | ||||
| #endif /* WITH_OPENVDB */ | #endif /* WITH_OPENVDB */ | ||||
| void BKE_volume_grid_selection_surface(const Volume *volume, | void BKE_volume_grid_selection_surface(const Volume *volume, | ||||
| const VolumeGrid *volume_grid, | const VolumeGrid *volume_grid, | ||||
| BKE_volume_selection_surface_cb cb, | BKE_volume_selection_surface_cb cb, | ||||
| Show All 36 Lines | |||||