28link(NxSoftBody *softbodyPtr) {
33 _ptr->userData =
this;
38 scene->_softbodies.add(
this);
48 _ptr->userData =
nullptr;
49 _error_type = ET_released;
52 scene->_softbodies.remove(
this);
63 nassertv(_error_type == ET_ok);
66 _ptr->getScene().releaseSoftBody(*_ptr);
83 _ptr->getWorldBounds(bounds);
87 _node->set_bounds(&bb);
97 nassertr(_error_type == ET_ok,
nullptr);
98 return (
PhysxScene *)_ptr->getScene().userData;
105get_soft_body_node()
const {
107 nassertr(_error_type == ET_ok,
nullptr);
115create_soft_body_node(
const char *name) {
117 nassertr(_error_type == ET_ok,
nullptr);
120 _node->allocate(
this);
132 nassertv(_error_type == ET_ok);
134 _name = name ? name :
"";
135 _ptr->setName(_name.c_str());
144 nassertr(_error_type == ET_ok,
"");
145 return _ptr->getName();
155 nassertv(_error_type == ET_ok);
156 nassertv(group >= 0 && group < 32);
157 _ptr->setGroup(group);
166 nassertr(_error_type == ET_ok, 0);
167 return _ptr->getGroup();
176 nassertv(_error_type == ET_ok);
178 NxGroupsMask _mask = mask.get_mask();
179 _ptr->setGroupsMask(_mask);
190 nassertr(_error_type == ET_ok, mask);
192 NxGroupsMask _mask = _ptr->getGroupsMask();
193 mask.set_mask(_mask);
204 nassertr(_error_type == ET_ok, 0);
205 return _ptr->getNumberOfParticles();
214 nassertv(_error_type == ET_ok);
215 _ptr->setParticleRadius(radius);
224 nassertr(_error_type == ET_ok, 0.0f);
225 return _ptr->getParticleRadius();
232set_flag(PhysxSoftBodyFlag flag,
bool value) {
234 nassertv(_error_type == ET_ok);
236 NxU32 flags = _ptr->getFlags();
245 _ptr->setFlags(flags);
252get_flag(PhysxSoftBodyFlag flag)
const {
254 nassertr(_error_type == ET_ok,
false);
256 return (_ptr->getFlags() & flag) ? true :
false;
265 nassertr(_error_type == ET_ok, 0.0f);
266 return _ptr->getDensity();
278 nassertr(_error_type == ET_ok, 0.0f);
279 return _ptr->getRelativeGridSpacing();
288 nassertv(_error_type == ET_ok);
289 ptr()->setVolumeStiffness(stiffness);
298 nassertr(_error_type == ET_ok, 0.0f);
299 return ptr()->getVolumeStiffness();
308 nassertv(_error_type == ET_ok);
309 ptr()->setStretchingStiffness(stiffness);
318 nassertr(_error_type == ET_ok, 0.0f);
319 return ptr()->getStretchingStiffness();
328 nassertv(_error_type == ET_ok);
329 ptr()->setDampingCoefficient(coef);
338 nassertr(_error_type == ET_ok, 0.0f);
339 return ptr()->getDampingCoefficient();
348 nassertv(_error_type == ET_ok);
349 ptr()->setFriction(friction);
358 nassertr(_error_type == ET_ok, 0.0f);
359 return ptr()->getFriction();
368 nassertv(_error_type == ET_ok);
369 nassertv(factor > 1.0f);
370 ptr()->setTearFactor(factor);
379 nassertr(_error_type == ET_ok, 0.0f);
380 return ptr()->getTearFactor();
389 nassertv(_error_type == ET_ok);
390 nassertv(factor > 1.0f);
391 ptr()->setAttachmentTearFactor(factor);
400 nassertr(_error_type == ET_ok, 0.0f);
401 return ptr()->getAttachmentTearFactor();
410 nassertv(_error_type == ET_ok);
411 ptr()->setSolverIterations(iterations);
420 nassertr(_error_type == ET_ok, 0);
421 return ptr()->getSolverIterations();
436 nassertr(_error_type == ET_ok,
false);
437 return _ptr->isSleeping();
448wake_up(
float wakeCounterValue) {
450 nassertv(_error_type == ET_ok);
451 _ptr->wakeUp(wakeCounterValue);
464 nassertv(_error_type == ET_ok);
479 nassertv(_error_type == ET_ok);
480 _ptr->setSleepLinearVelocity(threshold);
491 nassertr(_error_type == ET_ok, 0.0f);
492 return _ptr->getSleepLinearVelocity();
495#if NX_SDK_VERSION_NUMBER > 281
500set_self_collision_thickness(
float thickness) {
502 nassertv(_error_type == ET_ok);
503 _ptr->setSelfCollisionThickness(thickness);
510get_self_collision_thickness()
const {
512 nassertr(_error_type == ET_ok, 0.0f);
513 return _ptr->getSelfCollisionThickness();
520set_hard_stretch_limitation_factor(
float factor) {
522 nassertv(_error_type == ET_ok);
523 ptr()->setHardStretchLimitationFactor(factor);
530get_hard_stretch_limitation_factor()
const {
532 nassertr(_error_type == ET_ok, 0.0f);
533 return ptr()->getHardStretchLimitationFactor();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
A scene is a collection of bodies, constraints, and effectors which can interact.
Renderable geometry which represents a soft body mesh.
unsigned int get_group() const
Retrieves the collision group this soft body is part of.
float get_particle_radius() const
Gets the soft body particle radius.
float get_attachment_tear_factor() const
Retrieves the attachment soft body tear factor.
float get_stretching_stiffness() const
Retrieves the soft body stretching stiffness.
const char * get_name() const
Retrieves the name string.
void set_particle_radius(float radius)
Sets the soft body particle radius (must be positive).
bool is_sleeping() const
Returns true if this soft body is sleeping.
unsigned int get_solver_iterations() const
Retrieves the soft body solver iterations.
void set_attachment_tear_factor(float factor)
Sets the soft body attachment tear factor (must be larger than one).
float get_friction() const
Retrieves the soft body friction coefficient.
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the soft body if it is sleeping.
unsigned int get_num_particles()
Gets the number of cloth particles.
void set_tear_factor(float factor)
Sets the soft body tear factor (must be larger than one).
float get_volume_stiffness() const
Retrieves the soft body volume stiffness.
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
float get_tear_factor() const
Retrieves the soft body tear factor.
void set_flag(PhysxSoftBodyFlag flag, bool value)
Sets the value of a single flag.
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
void set_friction(float friction)
Sets the soft body friction coefficient in the range from 0 to 1.
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
void put_to_sleep()
Forces the soft body to sleep.
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an soft body may go to sleep.
PhysxScene * get_scene() const
Returns the scene which this soft body belongs to.
void set_group(unsigned int group)
Sets which collision group this soft body is part of.
float get_density() const
Gets the soft body density.
bool get_flag(PhysxSoftBodyFlag flag) const
Retrieves the value of a single flag.
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.
void set_volume_stiffness(float stiffness)
Sets the soft body volume stiffness in the range from 0 to 1.
void set_damping_coefficient(float coef)
Sets the damping coefficient in the range from 0 to 1.
float get_damping_coefficient() const
Retrieves the damping coefficient.
void set_stretching_stiffness(float stiffness)
Sets the soft body stretching stiffness in the range from 0 to 1.
void set_solver_iterations(unsigned int iterations)
Sets the soft body solver iterations.
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.