Blender V4.3
sculpt_cloth.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_index_mask_fwd.hh"
13#include "BLI_map.hh"
14#include "BLI_math_vector.hh"
15#include "BLI_vector.hh"
16
17#include "BKE_collision.h"
18
19struct Brush;
20struct Sculpt;
21struct SculptSession;
22namespace blender::bke::pbvh {
23class Node;
24}
25
27
28/* Cloth Simulation. */
30 /* Constraints were not built for this node, so it can't be simulated. */
32
33 /* There are constraints for the geometry in this node, but it should not be simulated. */
35
36 /* There are constraints for this node and they should be used by the solver. */
38};
39
41 /* Constraint that creates the structure of the cloth. */
43 /* Constraint that references the position of a vertex and a position in deformation_pos which
44 * can be deformed by the tools. */
46 /* Constraint that references the vertex position and a editable soft-body position for
47 * plasticity. */
49 /* Constraint that references the vertex position and its initial position. */
51};
52
54 /* Elements that are affected by the constraint. */
55 /* Element a should always be a mesh vertex with the index stored in elem_index_a as it is always
56 * deformed. Element b could be another vertex of the same mesh or any other position (arbitrary
57 * point, position for a previous state). In that case, elem_index_a and elem_index_b should be
58 * the same to avoid affecting two different vertices when solving the constraints.
59 * *elem_position points to the position which is owned by the element. */
62
65
66 float length;
67 float strength;
68
69 /* Index in #SimulationData.node_state of the node from where this constraint was created.
70 * This constraints will only be used by the solver if the state is active. */
71 int node;
72
74};
75
106
107/* Public functions. */
108
109std::unique_ptr<SimulationData> brush_simulation_create(const Depsgraph &depsgraph,
110 Object &ob,
111 float cloth_mass,
112 float cloth_damping,
113 float cloth_softbody_strength,
114 bool use_collisions,
115 bool needs_deform_coords);
116
117void sim_activate_nodes(Object &object, SimulationData &cloth_sim, const IndexMask &node_mask);
118
119void brush_store_simulation_state(const Depsgraph &depsgraph,
120 const Object &object,
121 SimulationData &cloth_sim);
122
123void do_simulation_step(const Depsgraph &depsgraph,
124 const Sculpt &sd,
125 Object &ob,
126 SimulationData &cloth_sim,
127 const IndexMask &node_mask);
128
129void ensure_nodes_constraints(const Sculpt &sd,
130 Object &ob,
131 const IndexMask &node_mask,
132 SimulationData &cloth_sim,
133 const float3 &initial_location,
134 float radius);
135
139void simulation_limits_draw(uint gpuattr,
140 const Brush &brush,
141 const float location[3],
142 const float normal[3],
143 float rds,
144 float line_width,
145 const float outline_col[3],
146 float alpha);
148 SculptSession &ss,
149 const float outline_col[3],
150 float outline_alpha);
151
153 const Brush &brush,
154 IndexMaskMemory &memory);
155
156bool is_cloth_deform_brush(const Brush &brush);
157
158} // namespace blender::ed::sculpt_paint::cloth
unsigned int uint
const Depsgraph * depsgraph
void plane_falloff_preview_draw(const uint gpuattr, SculptSession &ss, const float outline_col[3], float outline_alpha)
bool is_cloth_deform_brush(const Brush &brush)
void brush_store_simulation_state(const Depsgraph &depsgraph, const Object &object, SimulationData &cloth_sim)
void ensure_nodes_constraints(const Sculpt &sd, Object &object, const IndexMask &node_mask, SimulationData &cloth_sim, const float3 &initial_location, const float radius)
void sim_activate_nodes(Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
IndexMask brush_affected_nodes_gather(const Object &object, const Brush &brush, IndexMaskMemory &memory)
void do_simulation_step(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
void simulation_limits_draw(const uint gpuattr, const Brush &brush, const float location[3], const float normal[3], const float rds, const float line_width, const float outline_col[3], const float alpha)
std::unique_ptr< SimulationData > brush_simulation_create(const Depsgraph &depsgraph, Object &ob, const float cloth_mass, const float cloth_damping, const float cloth_softbody_strength, const bool use_collisions, const bool needs_deform_coords)
Map< const bke::pbvh::Node *, int > node_state_index