载入中...
搜索中...
未找到
eve::physics::Cloth类 参考

Interactive 2D cloth — Verlet particles + distance constraints. Pixel space (same convention as Box2D World). Script-owned. 更多...

#include <Cloth.h>

类 eve::physics::Cloth 继承关系图:
eve::physics::ISimulationBackend

Public 成员函数

 Cloth (int cols, int rows, float spacing, float originX, float originY)
 Cloth.
 
 ~Cloth ()
 Cloth.
 
 Cloth (const Cloth &)=delete
 
Cloth & operator= (const Cloth &)=delete
 
void update (float dt)
 Updates .
 
eve::Result< void > step (const eve::SimulationStep &step, const SimulationSettings &settings) override
 Advances cloth with the shared ticked backend contract.
 
SimulationObservation observation () const noexcept override
 Returns completed tick/time observables.
 
SimulationBackendKind kind () const noexcept override
 Identifies this production CPU cloth backend.
 
SimulationDeterminism determinism () const noexcept override
 CPU cloth uses bounded floating-point determinism.
 
eve::Result< void > restoreObservation (const SimulationObservation &observation) override
 Restores tick/progress metadata after an owner-level restore.
 
void setGravity (float gx, float gy)
 Sets the gravity.
 
float getGravityX () const
 Returns the gravity x.
 
float getGravityY () const
 Returns the gravity y.
 
void setStiffness (float stiffness)
 Constraint relaxation strength in [0,1] (default 0.85).
 
float getStiffness () const
 Returns the stiffness.
 
void setIterations (int iterations)
 Constraint solver iterations per substep (default 4).
 
int getIterations () const
 Returns the iterations.
 
void setDamping (float damping)
 Damping applied to Verlet velocity [0,1] (default 0.01).
 
float getDamping () const
 Returns the damping.
 
void setParticleSize (float size)
 Particle radius used for self-collision, draw size and body collision Default is 3. Two particles keep at least twice this size apart when self-collision is on.
 
float getParticleSize () const
 Returns the particle size.
 
void setParticleMass (float mass)
 Implicit particle mass in kg (default 0.1). Used for mass-proportional momentum exchange when colliding with dynamic rigid bodies.
 
float getParticleMass () const
 Returns the particle mass.
 
void setSelfCollision (bool on)
 Enable proximity-based self-collision between non-adjacent particles Default is true.
 
bool getSelfCollision () const
 Returns the self collision.
 
void setFoldStiffness (float k)
 Strength of the fold-angle clamp [0,1] (default 0.5).
 
float getFoldStiffness () const
 Returns the fold stiffness.
 
void setMaxFoldAngle (float degrees)
 Maximum bend deviation from a straight row/column segment in degrees Range is 0..180 degrees; default is 90. Prevents sharp creases and excessive folding.
 
float getMaxFoldAngle () const
 Returns the max fold angle.
 
void setBounds (float x, float y, float w, float h)
 Axis-aligned walls; particles bounce inside. Disabled if w/h <= 0.
 
void clearBounds ()
 Clears bounds.
 
void pin (int index)
 Pin.
 
void unpin (int index)
 Unpin.
 
void pinTopRow ()
 Pin top row.
 
bool isPinned (int index) const
 True when pinned.
 
int grabAt (float x, float y, float radius=24.f)
 Grab nearest free particle within radius (pixels). Returns particle index, or -1 if none.
 
void moveGrab (float x, float y)
 Moves grab.
 
void releaseGrab ()
 Release grab.
 
bool isGrabbing () const
 True when grabbing.
 
int getGrabIndex () const
 Returns the grab index.
 
void applyForce (float fx, float fy)
 Applies force.
 
void interactAt (float x, float y, float radius, float strength)
 Pointer-field interaction like Fluid2D::interactAt: positive strength attracts, negative repels. Applied as acceleration within radius (pixels) during the next update.
 
void setCollideWorld (World *world)
 Attach a 2D World so free particles collide with its non-sensor fixtures in pixel space. Passing null detaches it. Dynamic bodies receive a small push.
 
World * getCollideWorld () const
 Returns the attached collision world, or null when detached.
 
void reset ()
 Restore the flat grid pose (top row pinned) and clear transient state.
 
void setColor (float r, float g, float b, float a=1.f)
 Sets the color.
 
float getColorR () const
 Returns the color r.
 
float getColorG () const
 Returns the color g.
 
float getColorB () const
 Returns the color b.
 
float getColorA () const
 Returns the color a.
 
void draw (graphics::Graphics *gfx)
 Draws .
 
int getCols () const
 Returns the cols.
 
int getRows () const
 Returns the rows.
 
int getParticleCount () const
 Returns the particle count.
 
float getParticleX (int index) const
 Returns the particle x.
 
float getParticleY (int index) const
 Returns the particle y.
 
void setParticlePosition (int index, float x, float y)
 Sets the particle position.
 
float getSpacing () const
 Returns the spacing.
 
float getOriginX () const
 Returns the origin x.
 
float getOriginY () const
 Returns the origin y.
 
void destroy ()
 Destroys .
 
- Public 成员函数 继承自 eve::physics::ISimulationBackend
virtual ~ISimulationBackend ()=default
 Releases the backend; borrowed domain state is not destroyed.
 

详细描述

Interactive 2D cloth — Verlet particles + distance constraints. Pixel space (same convention as Box2D World). Script-owned.

Supports optional self-collision (spatial-hash proximity), a fold-angle limit that prevents sharp creases, and particle-vs-rigid-body collision when attached to a 2D World via setCollideWorld.

在文件 Cloth.h 第 28 行定义.

构造及析构函数说明

◆ Cloth() [1/2]

eve::physics::Cloth::Cloth ( int  cols,
int  rows,
float  spacing,
float  originX,
float  originY 
)

Cloth.

参数
colsgrid columns (>= 2)
rowsgrid rows (>= 2)
spacingparticle spacing in pixels
originXtop-left particle X (pixels)
originYtop-left particle Y (pixels)

在文件 Cloth.cpp 第 23 行定义.

引用了 c, p, pinTopRow() , 以及 r.

◆ ~Cloth()

eve::physics::Cloth::~Cloth ( )

Cloth.

在文件 Cloth.cpp 第 43 行定义.

引用了 destroy().

◆ Cloth() [2/2]

eve::physics::Cloth::Cloth ( const Cloth &  )
delete

成员函数说明

◆ applyForce()

void eve::physics::Cloth::applyForce ( float  fx,
float  fy 
)

Applies force.

Uniform wind / force impulse applied this frame (pixels/s² * mass).

在文件 Cloth.cpp 第 221 行定义.

◆ clearBounds()

void eve::physics::Cloth::clearBounds ( )

Clears bounds.

在文件 Cloth.cpp 第 168 行定义.

被这些函数引用 setBounds().

◆ destroy()

void eve::physics::Cloth::destroy ( )

Destroys .

在文件 Cloth.cpp 第 45 行定义.

被这些函数引用 ~Cloth().

◆ determinism()

SimulationDeterminism eve::physics::Cloth::determinism ( ) const
inlineoverridevirtualnoexcept

CPU cloth uses bounded floating-point determinism.

实现了 eve::physics::ISimulationBackend.

在文件 Cloth.h 第 56 行定义.

◆ draw()

void eve::physics::Cloth::draw ( graphics::Graphics *  gfx)

Draws .

在文件 Cloth.cpp 第 605 行定义.

引用了 a, b, eve::graphics::Graphics::drawSolidRect(), dx, dy, p, s, steps , 以及 t.

◆ getCollideWorld()

World * eve::physics::Cloth::getCollideWorld ( ) const
inline

Returns the attached collision world, or null when detached.

返回
Borrowed nullable World pointer owned by the physics registry. @ownership Cloth does not own the world and callers must not delete it. @lifetime Valid until the world is destroyed or detached. @thread Call on the owning physics thread. @reentrancy The accessor invokes no callbacks and is invalid across world mutation.

在文件 Cloth.h 第 184 行定义.

◆ getColorA()

float eve::physics::Cloth::getColorA ( ) const
inline

Returns the color a.

在文件 Cloth.h 第 198 行定义.

◆ getColorB()

float eve::physics::Cloth::getColorB ( ) const
inline

Returns the color b.

在文件 Cloth.h 第 196 行定义.

◆ getColorG()

float eve::physics::Cloth::getColorG ( ) const
inline

Returns the color g.

在文件 Cloth.h 第 194 行定义.

◆ getColorR()

float eve::physics::Cloth::getColorR ( ) const
inline

Returns the color r.

在文件 Cloth.h 第 192 行定义.

◆ getCols()

int eve::physics::Cloth::getCols ( ) const
inline

Returns the cols.

在文件 Cloth.h 第 204 行定义.

◆ getDamping()

float eve::physics::Cloth::getDamping ( ) const
inline

Returns the damping.

在文件 Cloth.h 第 83 行定义.

◆ getFoldStiffness()

float eve::physics::Cloth::getFoldStiffness ( ) const
inline

Returns the fold stiffness.

在文件 Cloth.h 第 113 行定义.

◆ getGrabIndex()

int eve::physics::Cloth::getGrabIndex ( ) const
inline

Returns the grab index.

在文件 Cloth.h 第 150 行定义.

◆ getGravityX()

float eve::physics::Cloth::getGravityX ( ) const
inline

Returns the gravity x.

在文件 Cloth.h 第 66 行定义.

◆ getGravityY()

float eve::physics::Cloth::getGravityY ( ) const
inline

Returns the gravity y.

在文件 Cloth.h 第 68 行定义.

◆ getIterations()

int eve::physics::Cloth::getIterations ( ) const
inline

Returns the iterations.

在文件 Cloth.h 第 78 行定义.

◆ getMaxFoldAngle()

float eve::physics::Cloth::getMaxFoldAngle ( ) const
inline

Returns the max fold angle.

在文件 Cloth.h 第 122 行定义.

◆ getOriginX()

float eve::physics::Cloth::getOriginX ( ) const
inline

Returns the origin x.

在文件 Cloth.h 第 219 行定义.

◆ getOriginY()

float eve::physics::Cloth::getOriginY ( ) const
inline

Returns the origin y.

在文件 Cloth.h 第 221 行定义.

◆ getParticleCount()

int eve::physics::Cloth::getParticleCount ( ) const
inline

Returns the particle count.

在文件 Cloth.h 第 208 行定义.

被这些函数引用 grabAt().

◆ getParticleMass()

float eve::physics::Cloth::getParticleMass ( ) const
inline

Returns the particle mass.

在文件 Cloth.h 第 100 行定义.

◆ getParticleSize()

float eve::physics::Cloth::getParticleSize ( ) const
inline

Returns the particle size.

在文件 Cloth.h 第 92 行定义.

◆ getParticleX()

float eve::physics::Cloth::getParticleX ( int  index) const

Returns the particle x.

在文件 Cloth.cpp 第 411 行定义.

引用了 index , 以及 x.

◆ getParticleY()

float eve::physics::Cloth::getParticleY ( int  index) const

Returns the particle y.

在文件 Cloth.cpp 第 416 行定义.

引用了 index , 以及 y.

◆ getRows()

int eve::physics::Cloth::getRows ( ) const
inline

Returns the rows.

在文件 Cloth.h 第 206 行定义.

◆ getSelfCollision()

bool eve::physics::Cloth::getSelfCollision ( ) const
inline

Returns the self collision.

在文件 Cloth.h 第 108 行定义.

◆ getSpacing()

float eve::physics::Cloth::getSpacing ( ) const
inline

Returns the spacing.

在文件 Cloth.h 第 217 行定义.

◆ getStiffness()

float eve::physics::Cloth::getStiffness ( ) const
inline

Returns the stiffness.

在文件 Cloth.h 第 73 行定义.

◆ grabAt()

int eve::physics::Cloth::grabAt ( float  x,
float  y,
float  radius = 24.f 
)

Grab nearest free particle within radius (pixels). Returns particle index, or -1 if none.

在文件 Cloth.cpp 第 190 行定义.

引用了 best, dx, dy, getParticleCount(), moveGrab(), p, radius, x , 以及 y.

◆ interactAt()

void eve::physics::Cloth::interactAt ( float  x,
float  y,
float  radius,
float  strength 
)

Pointer-field interaction like Fluid2D::interactAt: positive strength attracts, negative repels. Applied as acceleration within radius (pixels) during the next update.

在文件 Cloth.cpp 第 226 行定义.

引用了 radius, strength, x , 以及 y.

◆ isGrabbing()

bool eve::physics::Cloth::isGrabbing ( ) const
inline

True when grabbing.

在文件 Cloth.h 第 148 行定义.

◆ isPinned()

bool eve::physics::Cloth::isPinned ( int  index) const

True when pinned.

在文件 Cloth.cpp 第 185 行定义.

引用了 index , 以及 pinned.

◆ kind()

SimulationBackendKind eve::physics::Cloth::kind ( ) const
inlineoverridevirtualnoexcept

Identifies this production CPU cloth backend.

实现了 eve::physics::ISimulationBackend.

在文件 Cloth.h 第 54 行定义.

◆ moveGrab()

void eve::physics::Cloth::moveGrab ( float  x,
float  y 
)

Moves grab.

在文件 Cloth.cpp 第 208 行定义.

引用了 p, x , 以及 y.

被这些函数引用 grabAt().

◆ observation()

SimulationObservation eve::physics::Cloth::observation ( ) const
inlineoverridevirtualnoexcept

Returns completed tick/time observables.

实现了 eve::physics::ISimulationBackend.

在文件 Cloth.h 第 52 行定义.

被这些函数引用 restoreObservation().

◆ operator=()

Cloth & eve::physics::Cloth::operator= ( const Cloth &  )
delete

◆ pin()

void eve::physics::Cloth::pin ( int  index)

Pin.

在文件 Cloth.cpp 第 170 行定义.

引用了 index , 以及 pinned.

◆ pinTopRow()

void eve::physics::Cloth::pinTopRow ( )

Pin top row.

在文件 Cloth.cpp 第 180 行定义.

引用了 c.

被这些函数引用 Cloth() , 以及 reset().

◆ releaseGrab()

void eve::physics::Cloth::releaseGrab ( )

Release grab.

在文件 Cloth.cpp 第 219 行定义.

◆ reset()

void eve::physics::Cloth::reset ( )

Restore the flat grid pose (top row pinned) and clear transient state.

在文件 Cloth.cpp 第 47 行定义.

引用了 c, p, pinTopRow() , 以及 r.

◆ restoreObservation()

eve::Result< void > eve::physics::Cloth::restoreObservation ( const SimulationObservation &  observation)
overridevirtual

Restores tick/progress metadata after an owner-level restore.

重载 eve::physics::ISimulationBackend .

在文件 Cloth.cpp 第 594 行定义.

引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), observation(), eve::PreconditionViolation, eve::Status::success(), eve::Result< T >::success() , 以及 valid.

◆ setBounds()

void eve::physics::Cloth::setBounds ( float  x,
float  y,
float  w,
float  h 
)

Axis-aligned walls; particles bounce inside. Disabled if w/h <= 0.

在文件 Cloth.cpp 第 156 行定义.

引用了 clearBounds(), h, w, x , 以及 y.

◆ setCollideWorld()

void eve::physics::Cloth::setCollideWorld ( World *  world)

Attach a 2D World so free particles collide with its non-sensor fixtures in pixel space. Passing null detaches it. Dynamic bodies receive a small push.

Attach a borrowed 2D world for collision queries; null detaches it. @ownership Cloth never owns the World pointer; the physics registry owns it. @lifetime The association is valid only while the world remains alive; clear it before world destruction. @thread Call on the owning physics thread. @reentrancy Does not invoke callbacks; do not destroy the world re-entrantly.

在文件 Cloth.cpp 第 233 行定义.

引用了 world.

◆ setColor()

void eve::physics::Cloth::setColor ( float  r,
float  g,
float  b,
float  a = 1.f 
)

Sets the color.

在文件 Cloth.cpp 第 404 行定义.

引用了 a, b, g , 以及 r.

◆ setDamping()

void eve::physics::Cloth::setDamping ( float  damping)

Damping applied to Verlet velocity [0,1] (default 0.01).

在文件 Cloth.cpp 第 134 行定义.

◆ setFoldStiffness()

void eve::physics::Cloth::setFoldStiffness ( float  k)

Strength of the fold-angle clamp [0,1] (default 0.5).

在文件 Cloth.cpp 第 148 行定义.

◆ setGravity()

void eve::physics::Cloth::setGravity ( float  gx,
float  gy 
)

Sets the gravity.

在文件 Cloth.cpp 第 121 行定义.

◆ setIterations()

void eve::physics::Cloth::setIterations ( int  iterations)

Constraint solver iterations per substep (default 4).

在文件 Cloth.cpp 第 130 行定义.

引用了 iterations.

◆ setMaxFoldAngle()

void eve::physics::Cloth::setMaxFoldAngle ( float  degrees)

Maximum bend deviation from a straight row/column segment in degrees Range is 0..180 degrees; default is 90. Prevents sharp creases and excessive folding.

在文件 Cloth.cpp 第 152 行定义.

引用了 degrees.

◆ setParticleMass()

void eve::physics::Cloth::setParticleMass ( float  mass)

Implicit particle mass in kg (default 0.1). Used for mass-proportional momentum exchange when colliding with dynamic rigid bodies.

在文件 Cloth.cpp 第 142 行定义.

◆ setParticlePosition()

void eve::physics::Cloth::setParticlePosition ( int  index,
float  x,
float  y 
)

Sets the particle position.

在文件 Cloth.cpp 第 421 行定义.

引用了 index, p, x , 以及 y.

◆ setParticleSize()

void eve::physics::Cloth::setParticleSize ( float  size)

Particle radius used for self-collision, draw size and body collision Default is 3. Two particles keep at least twice this size apart when self-collision is on.

在文件 Cloth.cpp 第 138 行定义.

引用了 size.

◆ setSelfCollision()

void eve::physics::Cloth::setSelfCollision ( bool  on)

Enable proximity-based self-collision between non-adjacent particles Default is true.

在文件 Cloth.cpp 第 146 行定义.

◆ setStiffness()

void eve::physics::Cloth::setStiffness ( float  stiffness)

Constraint relaxation strength in [0,1] (default 0.85).

在文件 Cloth.cpp 第 126 行定义.

◆ step()

eve::Result< void > eve::physics::Cloth::step ( const eve::SimulationStep &  step,
const SimulationSettings &  settings 
)
overridevirtual

◆ unpin()

void eve::physics::Cloth::unpin ( int  index)

Unpin.

在文件 Cloth.cpp 第 175 行定义.

引用了 index , 以及 pinned.

◆ update()

void eve::physics::Cloth::update ( float  dt)

Updates .

在文件 Cloth.cpp 第 541 行定义.


该类的文档由以下文件生成: