载入中...
搜索中...
未找到
eve::graphics::hair::GroomInstance类 参考

Runtime groom drawable (UE UGroomComponent analogue). 更多...

#include <GroomInstance.h>

Public 成员函数

 GroomInstance (Graphics *gfx)
 Groom instance.
 
 ~GroomInstance ()
 Groom instance.
 
 GroomInstance (const GroomInstance &)=delete
 
GroomInstance & operator= (const GroomInstance &)=delete
 
 GroomInstance (GroomInstance &&)=delete
 
GroomInstance & operator= (GroomInstance &&)=delete
 
Result< void > setAsset (const GroomAsset &asset)
 Replace runtime strands from a shared asset (deep copy of groups). @ownership Asset remains owned by the caller; instance stores a copy.
 
Result< void > bakeProceduralPlane (float sizeX, float sizeZ, const ProceduralParams &params={})
 Bake a procedural plane groom into a single default group.
 
Result< void > bakeProceduralMesh (const float *posXYZ, const float *nrmXYZ, int vertexCount, const uint32_t *indices, int indexCount, const ProceduralParams &params={})
 Bake procedural strands on an indexed triangle mesh.
 
void setForcedLod (int lod)
 Force LOD index; -1 restores automatic selection.
 
int getForcedLod () const
 Returns the forced lod.
 
void setScreenSize (float screenSize)
 Screen-size hint in [0,1] used when forced LOD is disabled.
 
float getScreenSize () const
 Returns the screen size.
 
void setWidthScale (float scale)
 Sets the width scale.
 
float getWidthScale () const
 Returns the width scale.
 
void setSideHint (float x, float y, float z)
 Sets the side hint.
 
void setClusterCullingEnabled (bool enabled)
 Enable/disable CPU cluster frustum filtering before mesh bake. When enabled, call updateVisibility with the current view-projection.
 
bool isClusterCullingEnabled () const
 True when cluster culling enabled.
 
Result< void > updateVisibility (const float *viewProj16)
 Update the explicitly supplied visibility mask; equal masks do not dirty geometry. @cost Linear in tested clusters and visible curves; geometry publishes before the next draw.
 
void setMarschnerLobes (float r, float tt, float trt)
 Marschner-approximate lobe weights (R / TT / TRT) applied to the hair shader. Defaults: 1 / 0.45 / 0.25. Values are clamped to >= 0.
 
float getMarschnerR () const
 Returns the marschner r.
 
float getMarschnerTT () const
 Returns the marschner tt.
 
float getMarschnerTRT () const
 Returns the marschner trt.
 
void setSelfShadow (float strength, float bias, float rootAo)
 Cheap analytical self-shadow (fiber wrap + along-strand root AO).
 
float getSelfShadowStrength () const
 Returns the self shadow strength.
 
float getSelfShadowBias () const
 Returns the self shadow bias.
 
float getRootAoStrength () const
 Returns the root ao strength.
 
Result< void > rebuild ()
 Explicit synchronous refresh of pending geometry; clean instances are no-ops.
 
Result< void > enableGuideSimulation (const GuideSimParams &params={}, float guideFraction=0.15f, InterpolationMode mode=InterpolationMode::Offset)
 Enable lightweight guide XPBD/Verlet for every group.
 
Result< void > disableGuideSimulation ()
 Disable guide simulation and restore rest strands on next rebuild.
 
bool isGuideSimulationEnabled () const
 
void setGuideSimParams (const GuideSimParams &params)
 
const GuideSimParams & getGuideSimParams () const
 Returns the guide sim params.
 
Result< void > update (float dt)
 Advance guide simulation by dt; queue geometry for the next view preparation or draw. @cost Linear in guide/strand points for each simulation step. Geometry uploads coalesce; simulation steps never coalesce or drop elapsed time. Getters return the last published mesh. No-op success when simulation is disabled.
 
void draw (const glm::mat4 &model)
 
void draw ()
 Draws .
 
Mesh * getMesh () const
 Return the last published visible mesh, or null for a culled/empty groom. @ownership Borrowed from Graphics; geometry updates reuse this facade. @lifetime Until Graphics releases the mesh or shuts down; publication changes its contents. @thread Render owner thread; no preparation or callbacks.
 
Shader * getShader () const
 Returns the shader.
 
Texture * getTexture () const
 Returns the texture.
 
int getCurveCount () const
 Returns the curve count.
 
int getPointCount () const
 Returns the point count.
 
size_t getGroupCount () const
 Returns the group count.
 
int getActiveLodIndex () const
 Returns the active lod index.
 
int getActiveRepresentation () const
 Returns the active representation.
 
size_t getClusterCount () const
 Returns the cluster count.
 
int getVisibleCurveCount () const
 Returns the visible curve count.
 

详细描述

Runtime groom drawable (UE UGroomComponent analogue).

Rebuilds all groups into one combined GPU mesh (per-group LOD + optional cluster cull). Representation::Cards expands strands through graphics/HairCards polylines; Strands uses ribbon quads. Phase 3 exposes Marschner R/TT/TRT lobe weights and a cheap analytical self-shadow / root AO on the hair shader push constants. Phase 5 adds optional guide XPBD/Verlet via update(dt) (no physics-module include).

Caller owns the instance; Graphics owns Mesh / Shader / Texture and must outlive it. Width/side/forced-LOD/culling setters copy scalar desired state; equal values do nothing. Screen-size edits compare group LOD selections. Derived geometry publishes once in view preparation, or in explicit draw/rebuild. Getters never prepare resources. Destruction cancels the registered preparation callback.

@thread Render-thread affine; not safe to share across threads. @reentrancy draw must not re-enter Graphics resource creation.

在文件 GroomInstance.h 第 44 行定义.

构造及析构函数说明

◆ GroomInstance() [1/3]

eve::graphics::hair::GroomInstance::GroomInstance ( Graphics *  gfx)
explicit

◆ ~GroomInstance()

eve::graphics::hair::GroomInstance::~GroomInstance ( )

Groom instance.

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

引用了 eve::graphics::removeViewPreparation().

◆ GroomInstance() [2/3]

eve::graphics::hair::GroomInstance::GroomInstance ( const GroomInstance &  )
delete

◆ GroomInstance() [3/3]

eve::graphics::hair::GroomInstance::GroomInstance ( GroomInstance &&  )
delete

成员函数说明

◆ bakeProceduralMesh()

Result< void > eve::graphics::hair::GroomInstance::bakeProceduralMesh ( const float *  posXYZ,
const float *  nrmXYZ,
int  vertexCount,
const uint32_t *  indices,
int  indexCount,
const ProceduralParams &  params = {} 
)

Bake procedural strands on an indexed triangle mesh.

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

引用了 eve::Result< T >::failure(), eve::graphics::hair::generateOnMesh(), indexCount, indices, params, strands, value , 以及 vertexCount.

◆ bakeProceduralPlane()

Result< void > eve::graphics::hair::GroomInstance::bakeProceduralPlane ( float  sizeX,
float  sizeZ,
const ProceduralParams &  params = {} 
)

Bake a procedural plane groom into a single default group.

在文件 GroomAsset.cpp 第 291 行定义.

引用了 eve::Result< T >::failure(), eve::graphics::hair::generateOnPlane(), params, strands , 以及 value.

◆ disableGuideSimulation()

Result< void > eve::graphics::hair::GroomInstance::disableGuideSimulation ( )

Disable guide simulation and restore rest strands on next rebuild.

在文件 GroomAsset.cpp 第 430 行定义.

引用了 eve::graphics::hair::GroomAsset::groupCount() , 以及 eve::Result< T >::success().

◆ draw() [1/2]

void eve::graphics::hair::GroomInstance::draw ( )

Draws .

在文件 GroomAsset.cpp 第 681 行定义.

引用了 draw().

被这些函数引用 draw().

◆ draw() [2/2]

void eve::graphics::hair::GroomInstance::draw ( const glm::mat4 &  model)

◆ enableGuideSimulation()

Result< void > eve::graphics::hair::GroomInstance::enableGuideSimulation ( const GuideSimParams &  params = {},
float  guideFraction = 0.15f,
InterpolationMode  mode = InterpolationMode::Offset 
)

Enable lightweight guide XPBD/Verlet for every group.

Uses each group's guides when non-empty; otherwise extracts a guide subset from strands (guideFraction, default 0.15). Rest strands/guides and kNN weights are captured at enable time. Does not include the physics module — SoftBody3D can bridge later via capability.

在文件 GroomAsset.cpp 第 414 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::graphics::hair::GroomAsset::groupCount(), eve::InvalidArgument, params , 以及 eve::Result< T >::success().

◆ getActiveLodIndex()

int eve::graphics::hair::GroomInstance::getActiveLodIndex ( ) const

Returns the active lod index.

在文件 GroomAsset.cpp 第 479 行定义.

◆ getActiveRepresentation()

int eve::graphics::hair::GroomInstance::getActiveRepresentation ( ) const

Returns the active representation.

在文件 GroomAsset.cpp 第 481 行定义.

◆ getClusterCount()

size_t eve::graphics::hair::GroomInstance::getClusterCount ( ) const

Returns the cluster count.

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

引用了 state.

◆ getCurveCount()

int eve::graphics::hair::GroomInstance::getCurveCount ( ) const

Returns the curve count.

在文件 GroomAsset.cpp 第 692 行定义.

引用了 g, eve::graphics::hair::GroomAsset::groupAt() , 以及 eve::graphics::hair::GroomAsset::groupCount().

◆ getForcedLod()

int eve::graphics::hair::GroomInstance::getForcedLod ( ) const

Returns the forced lod.

在文件 GroomAsset.cpp 第 311 行定义.

◆ getGroupCount()

size_t eve::graphics::hair::GroomInstance::getGroupCount ( ) const

Returns the group count.

在文件 GroomAsset.cpp 第 477 行定义.

引用了 eve::graphics::hair::GroomAsset::groupCount().

◆ getGuideSimParams()

const GuideSimParams & eve::graphics::hair::GroomInstance::getGuideSimParams ( ) const

Returns the guide sim params.

在文件 GroomAsset.cpp 第 446 行定义.

◆ getMarschnerR()

float eve::graphics::hair::GroomInstance::getMarschnerR ( ) const

Returns the marschner r.

在文件 GroomAsset.cpp 第 358 行定义.

◆ getMarschnerTRT()

float eve::graphics::hair::GroomInstance::getMarschnerTRT ( ) const

Returns the marschner trt.

在文件 GroomAsset.cpp 第 362 行定义.

◆ getMarschnerTT()

float eve::graphics::hair::GroomInstance::getMarschnerTT ( ) const

Returns the marschner tt.

在文件 GroomAsset.cpp 第 360 行定义.

◆ getMesh()

Mesh * eve::graphics::hair::GroomInstance::getMesh ( ) const

Return the last published visible mesh, or null for a culled/empty groom. @ownership Borrowed from Graphics; geometry updates reuse this facade. @lifetime Until Graphics releases the mesh or shuts down; publication changes its contents. @thread Render owner thread; no preparation or callbacks.

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

◆ getPointCount()

int eve::graphics::hair::GroomInstance::getPointCount ( ) const

Returns the point count.

在文件 GroomAsset.cpp 第 701 行定义.

引用了 g, eve::graphics::hair::GroomAsset::groupAt() , 以及 eve::graphics::hair::GroomAsset::groupCount().

◆ getRootAoStrength()

float eve::graphics::hair::GroomInstance::getRootAoStrength ( ) const

Returns the root ao strength.

在文件 GroomAsset.cpp 第 375 行定义.

◆ getScreenSize()

float eve::graphics::hair::GroomInstance::getScreenSize ( ) const

Returns the screen size.

在文件 GroomAsset.cpp 第 325 行定义.

◆ getSelfShadowBias()

float eve::graphics::hair::GroomInstance::getSelfShadowBias ( ) const

Returns the self shadow bias.

在文件 GroomAsset.cpp 第 373 行定义.

◆ getSelfShadowStrength()

float eve::graphics::hair::GroomInstance::getSelfShadowStrength ( ) const

Returns the self shadow strength.

在文件 GroomAsset.cpp 第 371 行定义.

◆ getShader()

Shader * eve::graphics::hair::GroomInstance::getShader ( ) const

Returns the shader.

在文件 GroomAsset.cpp 第 473 行定义.

◆ getTexture()

Texture * eve::graphics::hair::GroomInstance::getTexture ( ) const

Returns the texture.

在文件 GroomAsset.cpp 第 475 行定义.

◆ getVisibleCurveCount()

int eve::graphics::hair::GroomInstance::getVisibleCurveCount ( ) const

Returns the visible curve count.

在文件 GroomAsset.cpp 第 489 行定义.

引用了 g, eve::graphics::hair::GroomAsset::groupAt(), eve::graphics::hair::GroomAsset::groupCount() , 以及 state.

◆ getWidthScale()

float eve::graphics::hair::GroomInstance::getWidthScale ( ) const

Returns the width scale.

在文件 GroomAsset.cpp 第 334 行定义.

◆ isClusterCullingEnabled()

bool eve::graphics::hair::GroomInstance::isClusterCullingEnabled ( ) const

True when cluster culling enabled.

在文件 GroomAsset.cpp 第 349 行定义.

◆ isGuideSimulationEnabled()

bool eve::graphics::hair::GroomInstance::isGuideSimulationEnabled ( ) const

在文件 GroomAsset.cpp 第 437 行定义.

◆ operator=() [1/2]

GroomInstance & eve::graphics::hair::GroomInstance::operator= ( const GroomInstance &  )
delete

◆ operator=() [2/2]

GroomInstance & eve::graphics::hair::GroomInstance::operator= ( GroomInstance &&  )
delete

◆ rebuild()

◆ setAsset()

Result< void > eve::graphics::hair::GroomInstance::setAsset ( const GroomAsset &  asset)

Replace runtime strands from a shared asset (deep copy of groups). @ownership Asset remains owned by the caller; instance stores a copy.

返回
Structured failure preserving the previous asset and published mesh. @cost Deep copy, cluster construction and initial geometry upload scale with strand points; amortize at asset replacement, rather than calling every frame.

在文件 GroomAsset.cpp 第 244 行定义.

引用了 error, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), ok, rebuild(), eve::Result< T >::success() , 以及 eve::graphics::hair::GroomAsset::validate().

◆ setClusterCullingEnabled()

void eve::graphics::hair::GroomInstance::setClusterCullingEnabled ( bool  enabled)

Enable/disable CPU cluster frustum filtering before mesh bake. When enabled, call updateVisibility with the current view-projection.

在文件 GroomAsset.cpp 第 343 行定义.

引用了 enabled.

◆ setForcedLod()

void eve::graphics::hair::GroomInstance::setForcedLod ( int  lod)

Force LOD index; -1 restores automatic selection.

在文件 GroomAsset.cpp 第 305 行定义.

引用了 lod.

◆ setGuideSimParams()

void eve::graphics::hair::GroomInstance::setGuideSimParams ( const GuideSimParams &  params)

在文件 GroomAsset.cpp 第 439 行定义.

引用了 params , 以及 state.

◆ setMarschnerLobes()

void eve::graphics::hair::GroomInstance::setMarschnerLobes ( float  r,
float  tt,
float  trt 
)

Marschner-approximate lobe weights (R / TT / TRT) applied to the hair shader. Defaults: 1 / 0.45 / 0.25. Values are clamped to >= 0.

在文件 GroomAsset.cpp 第 351 行定义.

引用了 r.

◆ setScreenSize()

void eve::graphics::hair::GroomInstance::setScreenSize ( float  screenSize)

Screen-size hint in [0,1] used when forced LOD is disabled.

在文件 GroomAsset.cpp 第 313 行定义.

引用了 group, eve::graphics::hair::GroomAsset::groupAt(), eve::graphics::hair::GroomAsset::groupCount(), previous , 以及 eve::graphics::hair::selectLodIndex().

◆ setSelfShadow()

void eve::graphics::hair::GroomInstance::setSelfShadow ( float  strength,
float  bias,
float  rootAo 
)

Cheap analytical self-shadow (fiber wrap + along-strand root AO).

Not a deep shadow map / transmittance volume — see design doc vs UE groom deep shadows. Strength / bias / rootAo are clamped to [0,1]. Defaults: 0.35 / 0.25 / 0.3. Set strength to 0 to disable.

在文件 GroomAsset.cpp 第 364 行定义.

引用了 bias , 以及 strength.

◆ setSideHint()

void eve::graphics::hair::GroomInstance::setSideHint ( float  x,
float  y,
float  z 
)

Sets the side hint.

在文件 GroomAsset.cpp 第 336 行定义.

引用了 x, y , 以及 z.

◆ setWidthScale()

void eve::graphics::hair::GroomInstance::setWidthScale ( float  scale)

Sets the width scale.

在文件 GroomAsset.cpp 第 327 行定义.

引用了 scale.

◆ update()

Result< void > eve::graphics::hair::GroomInstance::update ( float  dt)

Advance guide simulation by dt; queue geometry for the next view preparation or draw. @cost Linear in guide/strand points for each simulation step. Geometry uploads coalesce; simulation steps never coalesce or drop elapsed time. Getters return the last published mesh. No-op success when simulation is disabled.

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

引用了 dt, eve::Result< T >::failure(), eve::graphics::hair::GroomAsset::groupCount(), eve::graphics::hair::interpolateStrands(), state, strands , 以及 eve::Result< T >::success().

◆ updateVisibility()

Result< void > eve::graphics::hair::GroomInstance::updateVisibility ( const float *  viewProj16)

Update the explicitly supplied visibility mask; equal masks do not dirty geometry. @cost Linear in tested clusters and visible curves; geometry publishes before the next draw.

The mask belongs to the caller's current view. Call before each view when drawing multiple views; automatic view preparation does not replace this explicit mask.

参数
viewProj16Column-major 4x4 view-projection (glm::mat4 layout).

在文件 GroomAsset.cpp 第 538 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::graphics::hair::GroomAsset::groupCount(), eve::InvalidArgument, state , 以及 eve::Result< T >::success().


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