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

GPU-accelerated 2D cloth — Verlet integration and distance-constraint relaxation run in a Vulkan compute shader; positions are read back each frame for drawing. Same pixel-space conventions and script API shape as Cloth. 更多...

#include <ClothGPU.h>

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

Public 成员函数

 ClothGPU (eve::gpgpu::Gpgpu *gpgpu, int cols, int rows, float spacing, float originX, float originY)
 Cloth gpu.
 
 ~ClothGPU ()
 Cloth gpu.
 
 ClothGPU (const ClothGPU &)=delete
 
ClothGPU & operator= (const ClothGPU &)=delete
 
void update (float dt)
 Updates .
 
eve::Result< void > step (const eve::SimulationStep &step, const SimulationSettings &settings) override
 Advances the production GPU cloth with the shared ticked contract.
 
SimulationObservation observation () const noexcept override
 Returns completed tick/time observables.
 
SimulationBackendKind kind () const noexcept override
 Identifies this real accelerator backend.
 
SimulationDeterminism determinism () const noexcept override
 GPU/CPU parity is numerically bounded, not bit exact.
 
std::string getBackendName () const
 Return stable backend name for scripts and diagnostics.
 
bool supportsFeature (const std::string &feature) const
 Query a stable cloth feature name; unsupported features never silently fall back.
 
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 draw size in pixels (default 3).
 
float getParticleSize () const
 Returns the particle size.
 
void setSelfCollision (bool on)
 Enable proximity-based self-collision between non-adjacent particles Default is false. Particles keep at least twice particleSize apart. When bounds are set, uses a GPU spatial hash (atomicExchange linked lists per cell, overflow-free) with 3x3 neighbor traversal — scales to tens of thousands of particles. Without bounds it falls back to an O(n²) scan.
 
bool getSelfCollision () const
 Returns the self collision.
 
void setBounds (float x, float y, float w, float h)
 Axis-aligned walls; particles are clamped (with a small bounce).
 
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.
 
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 within radius (pixels) during the next update.
 
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)
 Draw links + particles from the latest GPU readback.
 
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.
 
float getSpacing () const
 Returns the spacing.
 
float getOriginX () const
 Returns the origin x.
 
float getOriginY () const
 Returns the origin y.
 
void reset ()
 Restore the flat grid pose (top row pinned) and re-upload state.
 
void destroy ()
 Destroys .
 
- Public 成员函数 继承自 eve::physics::ISimulationBackend
virtual ~ISimulationBackend ()=default
 Releases the backend; borrowed domain state is not destroyed.
 

静态 Public 属性

static constexpr int kMaxLinksPerParticle = 16
 

详细描述

GPU-accelerated 2D cloth — Verlet integration and distance-constraint relaxation run in a Vulkan compute shader; positions are read back each frame for drawing. Same pixel-space conventions and script API shape as Cloth.

One thread owns one particle and solves its fixed-size link list, so no atomics or ping-pong buffers are needed. Requires the Gpgpu module and a compute-capable Graphics backend; construction throws when unavailable.

在文件 ClothGPU.h 第 31 行定义.

构造及析构函数说明

◆ ClothGPU() [1/2]

eve::physics::ClothGPU::ClothGPU ( eve::gpgpu::Gpgpu *  gpgpu,
int  cols,
int  rows,
float  spacing,
float  originX,
float  originY 
)

Cloth gpu.

参数
gpgpuactive Gpgpu module (compute shader compiler + buffers)
colsgrid columns (>= 2)
rowsgrid rows (>= 2)
spacingparticle spacing in pixels
originXtop-left particle X (pixels)
originYtop-left particle Y (pixels)

在文件 ClothGPU.cpp 第 255 行定义.

引用了 c, count, getParticleCount(), gpgpu, eve::gpgpu::Sequence::isAvailable(), kMaxLinksPerParticle, eve::gpgpu::Gpgpu::newBuffer(), eve::gpgpu::Gpgpu::newSequence(), eve::gpgpu::Gpgpu::newShader() , 以及 r.

◆ ~ClothGPU()

eve::physics::ClothGPU::~ClothGPU ( )

Cloth gpu.

在文件 ClothGPU.cpp 第 297 行定义.

引用了 destroy().

◆ ClothGPU() [2/2]

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

成员函数说明

◆ applyForce()

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

Applies force.

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

在文件 ClothGPU.cpp 第 488 行定义.

◆ clearBounds()

void eve::physics::ClothGPU::clearBounds ( )

Clears bounds.

在文件 ClothGPU.cpp 第 462 行定义.

被这些函数引用 setBounds().

◆ destroy()

void eve::physics::ClothGPU::destroy ( )

Destroys .

在文件 ClothGPU.cpp 第 299 行定义.

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

◆ determinism()

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

GPU/CPU parity is numerically bounded, not bit exact.

实现了 eve::physics::ISimulationBackend.

在文件 ClothGPU.h 第 63 行定义.

◆ draw()

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

Draw links + particles from the latest GPU readback.

在文件 ClothGPU.cpp 第 664 行定义.

引用了 count, eve::graphics::Graphics::drawSolidRect(), dx, dy, getParticleCount(), kMaxLinksPerParticle, s, steps , 以及 t.

◆ getBackendName()

std::string eve::physics::ClothGPU::getBackendName ( ) const
inline

Return stable backend name for scripts and diagnostics.

在文件 ClothGPU.h 第 67 行定义.

◆ getColorA()

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

Returns the color a.

在文件 ClothGPU.h 第 145 行定义.

◆ getColorB()

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

Returns the color b.

在文件 ClothGPU.h 第 143 行定义.

◆ getColorG()

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

Returns the color g.

在文件 ClothGPU.h 第 141 行定义.

◆ getColorR()

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

Returns the color r.

在文件 ClothGPU.h 第 139 行定义.

◆ getCols()

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

Returns the cols.

在文件 ClothGPU.h 第 151 行定义.

◆ getDamping()

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

Returns the damping.

在文件 ClothGPU.h 第 94 行定义.

◆ getGravityX()

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

Returns the gravity x.

在文件 ClothGPU.h 第 77 行定义.

◆ getGravityY()

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

Returns the gravity y.

在文件 ClothGPU.h 第 79 行定义.

◆ getIterations()

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

Returns the iterations.

在文件 ClothGPU.h 第 89 行定义.

◆ getOriginX()

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

Returns the origin x.

在文件 ClothGPU.h 第 164 行定义.

◆ getOriginY()

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

Returns the origin y.

在文件 ClothGPU.h 第 166 行定义.

◆ getParticleCount()

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

Returns the particle count.

在文件 ClothGPU.h 第 155 行定义.

被这些函数引用 ClothGPU(), draw(), getParticleX(), getParticleY(), isPinned(), pin() , 以及 unpin().

◆ getParticleSize()

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

Returns the particle size.

在文件 ClothGPU.h 第 99 行定义.

◆ getParticleX()

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

Returns the particle x.

在文件 ClothGPU.cpp 第 507 行定义.

引用了 getParticleCount() , 以及 index.

◆ getParticleY()

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

Returns the particle y.

在文件 ClothGPU.cpp 第 512 行定义.

引用了 getParticleCount() , 以及 index.

◆ getRows()

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

Returns the rows.

在文件 ClothGPU.h 第 153 行定义.

◆ getSelfCollision()

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

Returns the self collision.

在文件 ClothGPU.h 第 110 行定义.

◆ getSpacing()

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

Returns the spacing.

在文件 ClothGPU.h 第 162 行定义.

◆ getStiffness()

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

Returns the stiffness.

在文件 ClothGPU.h 第 84 行定义.

◆ interactAt()

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

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

在文件 ClothGPU.cpp 第 493 行定义.

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

◆ isPinned()

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

True when pinned.

在文件 ClothGPU.cpp 第 483 行定义.

引用了 getParticleCount() , 以及 index.

◆ kind()

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

Identifies this real accelerator backend.

实现了 eve::physics::ISimulationBackend.

在文件 ClothGPU.h 第 61 行定义.

◆ observation()

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

Returns completed tick/time observables.

实现了 eve::physics::ISimulationBackend.

在文件 ClothGPU.h 第 59 行定义.

被这些函数引用 restoreObservation().

◆ operator=()

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

◆ pin()

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

Pin.

在文件 ClothGPU.cpp 第 464 行定义.

引用了 getParticleCount() , 以及 index.

◆ pinTopRow()

void eve::physics::ClothGPU::pinTopRow ( )

Pin top row.

在文件 ClothGPU.cpp 第 478 行定义.

引用了 c.

被这些函数引用 reset().

◆ reset()

void eve::physics::ClothGPU::reset ( )

Restore the flat grid pose (top row pinned) and re-upload state.

在文件 ClothGPU.cpp 第 517 行定义.

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

◆ restoreObservation()

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

◆ setBounds()

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

Axis-aligned walls; particles are clamped (with a small bounce).

在文件 ClothGPU.cpp 第 450 行定义.

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

◆ setColor()

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

Sets the color.

在文件 ClothGPU.cpp 第 500 行定义.

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

◆ setDamping()

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

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

在文件 ClothGPU.cpp 第 440 行定义.

◆ setGravity()

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

Sets the gravity.

在文件 ClothGPU.cpp 第 427 行定义.

◆ setIterations()

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

Constraint solver iterations per substep (default 4).

在文件 ClothGPU.cpp 第 436 行定义.

引用了 iterations.

◆ setParticleSize()

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

Particle draw size in pixels (default 3).

在文件 ClothGPU.cpp 第 444 行定义.

引用了 size.

◆ setSelfCollision()

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

Enable proximity-based self-collision between non-adjacent particles Default is false. Particles keep at least twice particleSize apart. When bounds are set, uses a GPU spatial hash (atomicExchange linked lists per cell, overflow-free) with 3x3 neighbor traversal — scales to tens of thousands of particles. Without bounds it falls back to an O(n²) scan.

在文件 ClothGPU.cpp 第 448 行定义.

◆ setStiffness()

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

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

在文件 ClothGPU.cpp 第 432 行定义.

◆ step()

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

◆ supportsFeature()

bool eve::physics::ClothGPU::supportsFeature ( const std::string &  feature) const

Query a stable cloth feature name; unsupported features never silently fall back.

在文件 ClothGPU.cpp 第 18 行定义.

◆ unpin()

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

Unpin.

在文件 ClothGPU.cpp 第 471 行定义.

引用了 getParticleCount() , 以及 index.

◆ update()

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

Updates .

在文件 ClothGPU.cpp 第 534 行定义.

类成员变量说明

◆ kMaxLinksPerParticle

constexpr int eve::physics::ClothGPU::kMaxLinksPerParticle = 16
staticconstexpr

在文件 ClothGPU.h 第 33 行定义.

被这些函数引用 ClothGPU() , 以及 draw().


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