28 link(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;
105 get_soft_body_node()
const {
107 nassertr(_error_type == ET_ok,
nullptr);
115 create_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();
234 nassertv(_error_type == ET_ok);
236 NxU32 flags = _ptr->getFlags();
245 _ptr->setFlags(flags);
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();
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 500 set_self_collision_thickness(
float thickness) {
502 nassertv(_error_type == ET_ok);
503 _ptr->setSelfCollisionThickness(thickness);
509 float PhysxSoftBody::
510 get_self_collision_thickness()
const {
512 nassertr(_error_type == ET_ok, 0.0f);
513 return _ptr->getSelfCollisionThickness();
520 set_hard_stretch_limitation_factor(
float factor) {
522 nassertv(_error_type == ET_ok);
523 ptr()->setHardStretchLimitationFactor(factor);
529 float PhysxSoftBody::
530 get_hard_stretch_limitation_factor()
const {
532 nassertr(_error_type == ET_ok, 0.0f);
533 return ptr()->getHardStretchLimitationFactor();
535 #endif // NX_SDK_VERSION_NUMBER > 281 PhysxScene * get_scene() const
Returns the scene which this soft body belongs to.
void set_attachment_tear_factor(float factor)
Sets the soft body attachment tear factor (must be larger than one).
bool is_sleeping() const
Returns true if this soft body is sleeping.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
float get_damping_coefficient() const
Retrieves the damping coefficient.
float get_tear_factor() const
Retrieves the soft body tear factor.
unsigned int get_solver_iterations() const
Retrieves the soft body solver iterations.
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the soft body if it is sleeping.
float get_density() const
Gets the soft body density.
A scene is a collection of bodies, constraints, and effectors which can interact.
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.
void set_particle_radius(float radius)
Sets the soft body particle radius (must be positive).
unsigned int get_group() const
Retrieves the collision group this soft body is part of.
bool get_flag(PhysxSoftBodyFlag flag) const
Retrieves the value of a single flag.
void set_group(unsigned int group)
Sets which collision group this soft body is part of.
void set_friction(float friction)
Sets the soft body friction coefficient in the range from 0 to 1.
void set_stretching_stiffness(float stiffness)
Sets the soft body stretching stiffness in the range from 0 to 1.
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
void set_flag(PhysxSoftBodyFlag flag, bool value)
Sets the value of a single flag.
Renderable geometry which represents a soft body mesh.
void set_tear_factor(float factor)
Sets the soft body tear factor (must be larger than one).
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
float get_particle_radius() const
Gets the soft body particle radius.
float get_friction() const
Retrieves the soft body friction coefficient.
void set_solver_iterations(unsigned int iterations)
Sets the soft body solver iterations.
const char * get_name() const
Retrieves the name string.
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an soft body may go to sleep.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
float get_attachment_tear_factor() const
Retrieves the attachment soft body tear factor.
float get_volume_stiffness() const
Retrieves the soft body volume stiffness.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void put_to_sleep()
Forces the soft body to sleep.
float get_stretching_stiffness() const
Retrieves the soft body stretching stiffness.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
unsigned int get_num_particles()
Gets the number of cloth particles.