RigsofRods
Soft-body Physics Simulation
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
RoR::FlexBody Class Reference

Flexbody = A deformable mesh; updated on CPU every frame, then uploaded to video memory. More...

#include <FlexBody.h>

+ Collaboration diagram for RoR::FlexBody:

Public Types

enum  PlaceholderType { PlaceholderType::NOT_A_PLACEHOLDER, PlaceholderType::TUNING_REMOVED_PLACEHOLDER, PlaceholderType::FAULTY_FORSET_PLACEHOLDER, PlaceholderType::FAULTY_MESH_PLACEHOLDER }
 

Public Member Functions

 FlexBody (PlaceholderType, FlexbodyID_t id, const std::string &orig_meshname)
 
 ~FlexBody ()
 
void reset ()
 
void updateBlend ()
 
void writeBlend ()
 
void computeFlexbody ()
 Updates mesh deformation; works on CPU using local copy of vertex data. More...
 
void updateFlexbodyVertexBuffers ()
 
bool isVisible () const
 
void setVisible (bool visible)
 
void setFlexbodyCastShadow (bool val)
 
int getVertexCount ()
 
Locator_tgetVertexLocator (int vert)
 
Ogre::Vector3 getVertexPos (int vert)
 
Ogre::Entity * getEntity ()
 
const std::string & getOrigMeshName () const
 
std::vector< NodeNum_t > & getForsetNodes ()
 
std::string getOrigMeshInfo ()
 
std::string getLiveMeshInfo ()
 
NodeNum_t getRefNode ()
 
NodeNum_t getXNode ()
 
NodeNum_t getYNode ()
 
FlexbodyID_t getID () const
 
PlaceholderType getPlaceholderType () const
 
void destroyOgreObjects ()
 

Static Public Member Functions

static const char * PlaceholderTypeToString (PlaceholderType type)
 

Data Fields

Visibility control (same as prop - see file GfxData.h)
CameraMode_t fb_camera_mode_active = CAMERA_MODE_ALWAYS_VISIBLE
 Dynamic visibility mode {0 and higher = cinecam index}. More...
 
CameraMode_t fb_camera_mode_orig = CAMERA_MODE_ALWAYS_VISIBLE
 Dynamic visibility mode {0 and higher = cinecam index}. More...
 

Private Member Functions

 FlexBody (RoR::FlexBodyCacheData *preloaded_from_cache, RoR::GfxActor *gfx_actor, Ogre::Entity *entity, NodeNum_t ref, NodeNum_t nx, NodeNum_t ny, Ogre::Vector3 offset, Ogre::Quaternion const &rot, std::vector< unsigned int > &node_indices)
 
void defragmentFlexbodyMesh ()
 

Private Attributes

RoR::GfxActorm_gfx_actor = nullptr
 
size_t m_vertex_count = 0
 
Ogre::Vector3 m_flexit_center = Ogre::Vector3::ZERO
 Updated per frame. More...
 
FlexbodyID_t m_id = FLEXBODYID_INVALID
 
PlaceholderType m_placeholder_type = PlaceholderType::NOT_A_PLACEHOLDER
 
Ogre::Vector3 * m_dst_pos = nullptr
 
Ogre::Vector3 * m_src_normals = nullptr
 
Ogre::Vector3 * m_dst_normals = nullptr
 
Ogre::ARGB * m_src_colors = nullptr
 
Locator_tm_locators = nullptr
 1 loc per vertex More...
 
NodeNum_t m_node_center = NODENUM_INVALID
 
NodeNum_t m_node_x = NODENUM_INVALID
 
NodeNum_t m_node_y = NODENUM_INVALID
 
Ogre::Vector3 m_center_offset = Ogre::Vector3::ZERO
 
Ogre::SceneNode * m_scene_node = nullptr
 
Ogre::Entity * m_scene_entity = nullptr
 
int m_camera_mode = CAMERA_MODE_ALWAYS_VISIBLE
 Visibility control {-2 = always, -1 = 3rdPerson only, 0+ = cinecam index}. More...
 
int m_shared_buf_num_verts = 0
 
Ogre::HardwareVertexBufferSharedPtr m_shared_vbuf_pos
 
Ogre::HardwareVertexBufferSharedPtr m_shared_vbuf_norm
 
Ogre::HardwareVertexBufferSharedPtr m_shared_vbuf_color
 
int m_num_submesh_vbufs = 0
 
int m_submesh_vbufs_vertex_counts [16]
 
Ogre::HardwareVertexBufferSharedPtr m_submesh_vbufs_pos [16]
 positions More...
 
Ogre::HardwareVertexBufferSharedPtr m_submesh_vbufs_norm [16]
 normals More...
 
Ogre::HardwareVertexBufferSharedPtr m_submesh_vbufs_color [16]
 colors More...
 
bool m_uses_shared_vertex_data = false
 
bool m_has_texture = true
 
bool m_has_texture_blend = true
 
bool m_blend_changed = false
 
std::vector< NodeNum_tm_forset_nodes
 
std::string m_orig_mesh_info
 
std::string m_orig_mesh_name
 

Friends

class RoR::FlexFactory
 
class RoR::FlexBodyFileIO
 

Detailed Description

Flexbody = A deformable mesh; updated on CPU every frame, then uploaded to video memory.

Definition at line 43 of file FlexBody.h.

Member Enumeration Documentation

◆ PlaceholderType

Enumerator
NOT_A_PLACEHOLDER 
TUNING_REMOVED_PLACEHOLDER 
FAULTY_FORSET_PLACEHOLDER 
FAULTY_MESH_PLACEHOLDER 

Definition at line 62 of file FlexBody.h.

Constructor & Destructor Documentation

◆ FlexBody() [1/2]

FlexBody::FlexBody ( RoR::FlexBodyCacheData preloaded_from_cache,
RoR::GfxActor gfx_actor,
Ogre::Entity *  entity,
NodeNum_t  ref,
NodeNum_t  nx,
NodeNum_t  ny,
Ogre::Vector3  offset,
Ogre::Quaternion const &  rot,
std::vector< unsigned int > &  node_indices 
)
private

Definition at line 38 of file FlexBody.cpp.

+ Here is the call graph for this function:

◆ FlexBody() [2/2]

FlexBody::FlexBody ( PlaceholderType  p_type,
FlexbodyID_t  id,
const std::string &  orig_meshname 
)

Definition at line 522 of file FlexBody.cpp.

◆ ~FlexBody()

FlexBody::~FlexBody ( )

Definition at line 530 of file FlexBody.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ computeFlexbody()

void FlexBody::computeFlexbody ( )

Updates mesh deformation; works on CPU using local copy of vertex data.

Definition at line 603 of file FlexBody.cpp.

+ Here is the call graph for this function:

◆ defragmentFlexbodyMesh()

void FlexBody::defragmentFlexbodyMesh ( )
private

Definition at line 776 of file FlexBody.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroyOgreObjects()

void FlexBody::destroyOgreObjects ( )

Definition at line 555 of file FlexBody.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEntity()

Ogre::Entity* RoR::FlexBody::getEntity ( )
inline

Definition at line 95 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getForsetNodes()

std::vector<NodeNum_t>& RoR::FlexBody::getForsetNodes ( )
inline

Definition at line 97 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getID()

FlexbodyID_t RoR::FlexBody::getID ( ) const
inline

Definition at line 105 of file FlexBody.h.

◆ getLiveMeshInfo()

std::string RoR::FlexBody::getLiveMeshInfo ( )
inline

Definition at line 99 of file FlexBody.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrigMeshInfo()

std::string RoR::FlexBody::getOrigMeshInfo ( )
inline

Definition at line 98 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getOrigMeshName()

const std::string& RoR::FlexBody::getOrigMeshName ( ) const
inline

Definition at line 96 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getPlaceholderType()

PlaceholderType RoR::FlexBody::getPlaceholderType ( ) const
inline

Definition at line 106 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getRefNode()

NodeNum_t RoR::FlexBody::getRefNode ( )
inline

Definition at line 101 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getVertexCount()

int RoR::FlexBody::getVertexCount ( )
inline

Definition at line 92 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getVertexLocator()

Locator_t& RoR::FlexBody::getVertexLocator ( int  vert)
inline

Definition at line 93 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getVertexPos()

Ogre::Vector3 RoR::FlexBody::getVertexPos ( int  vert)
inline

Definition at line 94 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getXNode()

NodeNum_t RoR::FlexBody::getXNode ( )
inline

Definition at line 102 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ getYNode()

NodeNum_t RoR::FlexBody::getYNode ( )
inline

Definition at line 103 of file FlexBody.h.

+ Here is the caller graph for this function:

◆ isVisible()

bool FlexBody::isVisible ( ) const

Definition at line 580 of file FlexBody.cpp.

◆ PlaceholderTypeToString()

const char * FlexBody::PlaceholderTypeToString ( PlaceholderType  type)
static

Definition at line 543 of file FlexBody.cpp.

+ Here is the caller graph for this function:

◆ reset()

void FlexBody::reset ( )

Definition at line 675 of file FlexBody.cpp.

+ Here is the call graph for this function:

◆ setFlexbodyCastShadow()

void FlexBody::setFlexbodyCastShadow ( bool  val)

Definition at line 596 of file FlexBody.cpp.

◆ setVisible()

void FlexBody::setVisible ( bool  visible)

Definition at line 589 of file FlexBody.cpp.

◆ updateBlend()

void FlexBody::updateBlend ( )

Definition at line 700 of file FlexBody.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFlexbodyVertexBuffers()

void FlexBody::updateFlexbodyVertexBuffers ( )

Definition at line 644 of file FlexBody.cpp.

+ Here is the call graph for this function:

◆ writeBlend()

void FlexBody::writeBlend ( )

Definition at line 684 of file FlexBody.cpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ RoR::FlexBodyFileIO

friend class RoR::FlexBodyFileIO
friend

Definition at line 46 of file FlexBody.h.

◆ RoR::FlexFactory

friend class RoR::FlexFactory
friend

Definition at line 45 of file FlexBody.h.

Field Documentation

◆ fb_camera_mode_active

CameraMode_t RoR::FlexBody::fb_camera_mode_active = CAMERA_MODE_ALWAYS_VISIBLE

Dynamic visibility mode {0 and higher = cinecam index}.

Definition at line 73 of file FlexBody.h.

◆ fb_camera_mode_orig

CameraMode_t RoR::FlexBody::fb_camera_mode_orig = CAMERA_MODE_ALWAYS_VISIBLE

Dynamic visibility mode {0 and higher = cinecam index}.

Definition at line 74 of file FlexBody.h.

◆ m_blend_changed

bool RoR::FlexBody::m_blend_changed = false
private

Definition at line 147 of file FlexBody.h.

◆ m_camera_mode

int RoR::FlexBody::m_camera_mode = CAMERA_MODE_ALWAYS_VISIBLE
private

Visibility control {-2 = always, -1 = 3rdPerson only, 0+ = cinecam index}.

Definition at line 131 of file FlexBody.h.

◆ m_center_offset

Ogre::Vector3 RoR::FlexBody::m_center_offset = Ogre::Vector3::ZERO
private

Definition at line 128 of file FlexBody.h.

◆ m_dst_normals

Ogre::Vector3* RoR::FlexBody::m_dst_normals = nullptr
private

Definition at line 121 of file FlexBody.h.

◆ m_dst_pos

Ogre::Vector3* RoR::FlexBody::m_dst_pos = nullptr
private

Definition at line 119 of file FlexBody.h.

◆ m_flexit_center

Ogre::Vector3 RoR::FlexBody::m_flexit_center = Ogre::Vector3::ZERO
private

Updated per frame.

Definition at line 115 of file FlexBody.h.

◆ m_forset_nodes

std::vector<NodeNum_t> RoR::FlexBody::m_forset_nodes
private

Definition at line 150 of file FlexBody.h.

◆ m_gfx_actor

RoR::GfxActor* RoR::FlexBody::m_gfx_actor = nullptr
private

Definition at line 113 of file FlexBody.h.

◆ m_has_texture

bool RoR::FlexBody::m_has_texture = true
private

Definition at line 145 of file FlexBody.h.

◆ m_has_texture_blend

bool RoR::FlexBody::m_has_texture_blend = true
private

Definition at line 146 of file FlexBody.h.

◆ m_id

FlexbodyID_t RoR::FlexBody::m_id = FLEXBODYID_INVALID
private

Definition at line 116 of file FlexBody.h.

◆ m_locators

Locator_t* RoR::FlexBody::m_locators = nullptr
private

1 loc per vertex

Definition at line 123 of file FlexBody.h.

◆ m_node_center

NodeNum_t RoR::FlexBody::m_node_center = NODENUM_INVALID
private

Definition at line 125 of file FlexBody.h.

◆ m_node_x

NodeNum_t RoR::FlexBody::m_node_x = NODENUM_INVALID
private

Definition at line 126 of file FlexBody.h.

◆ m_node_y

NodeNum_t RoR::FlexBody::m_node_y = NODENUM_INVALID
private

Definition at line 127 of file FlexBody.h.

◆ m_num_submesh_vbufs

int RoR::FlexBody::m_num_submesh_vbufs = 0
private

Definition at line 138 of file FlexBody.h.

◆ m_orig_mesh_info

std::string RoR::FlexBody::m_orig_mesh_info
private

Definition at line 151 of file FlexBody.h.

◆ m_orig_mesh_name

std::string RoR::FlexBody::m_orig_mesh_name
private

Definition at line 152 of file FlexBody.h.

◆ m_placeholder_type

PlaceholderType RoR::FlexBody::m_placeholder_type = PlaceholderType::NOT_A_PLACEHOLDER
private

Definition at line 117 of file FlexBody.h.

◆ m_scene_entity

Ogre::Entity* RoR::FlexBody::m_scene_entity = nullptr
private

Definition at line 130 of file FlexBody.h.

◆ m_scene_node

Ogre::SceneNode* RoR::FlexBody::m_scene_node = nullptr
private

Definition at line 129 of file FlexBody.h.

◆ m_shared_buf_num_verts

int RoR::FlexBody::m_shared_buf_num_verts = 0
private

Definition at line 133 of file FlexBody.h.

◆ m_shared_vbuf_color

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_shared_vbuf_color
private

Definition at line 136 of file FlexBody.h.

◆ m_shared_vbuf_norm

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_shared_vbuf_norm
private

Definition at line 135 of file FlexBody.h.

◆ m_shared_vbuf_pos

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_shared_vbuf_pos
private

Definition at line 134 of file FlexBody.h.

◆ m_src_colors

Ogre::ARGB* RoR::FlexBody::m_src_colors = nullptr
private

Definition at line 122 of file FlexBody.h.

◆ m_src_normals

Ogre::Vector3* RoR::FlexBody::m_src_normals = nullptr
private

Definition at line 120 of file FlexBody.h.

◆ m_submesh_vbufs_color

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_submesh_vbufs_color[16]
private

colors

Definition at line 142 of file FlexBody.h.

◆ m_submesh_vbufs_norm

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_submesh_vbufs_norm[16]
private

normals

Definition at line 141 of file FlexBody.h.

◆ m_submesh_vbufs_pos

Ogre::HardwareVertexBufferSharedPtr RoR::FlexBody::m_submesh_vbufs_pos[16]
private

positions

Definition at line 140 of file FlexBody.h.

◆ m_submesh_vbufs_vertex_counts

int RoR::FlexBody::m_submesh_vbufs_vertex_counts[16]
private

Definition at line 139 of file FlexBody.h.

◆ m_uses_shared_vertex_data

bool RoR::FlexBody::m_uses_shared_vertex_data = false
private

Definition at line 144 of file FlexBody.h.

◆ m_vertex_count

size_t RoR::FlexBody::m_vertex_count = 0
private

Definition at line 114 of file FlexBody.h.


The documentation for this class was generated from the following files: