HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_XformCache Class Reference

#include <OBJ_XformCache.h>

+ Inheritance diagram for OBJ_XformCache:

Public Types

enum  OBJ_XformType { WORLD_XFORM, LOCAL_XFORM }
 
enum  OBJ_LookupStatus { HIT, MISS_VERSION, MISS_DATA }
 
enum  { DEFAULT_CACHE_SIZE_KB = 150*1024 }
 
enum  OBJ_MemoryState { MEMORY_CHECK_NEVER, MEMORY_CHECK_ALWAYS }
 
typedef UT_ThreadSafeCache
< UT_RecursiveSpinLock
Policy
 

Public Member Functions

 OBJ_XformCache ()
 
 ~OBJ_XformCache () override
 
const UT_DMatrix4getXform (int id, fpreal time, OBJ_XformType type, OP_VERSION version, OBJ_LookupStatus &status)
 
bool setXform (int id, fpreal time, OBJ_XformType type, OP_VERSION version, const UT_DMatrix4 &xform)
 
void parseCommand (CMD_Args &args)
 
void setMemoryLimit (int64 max_memory)
 Sets the new memory limit for the cache size in bytes. More...
 
void clear ()
 Clears the cache and frees memory. More...
 
OBJ_MemoryState getMemoryState () const
 
- Public Member Functions inherited from UT_Cache
 UT_Cache ()
 
virtual ~UT_Cache ()
 
 UT_Cache (const UT_Cache &)=delete
 
UT_Cacheoperator= (const UT_Cache &)=delete
 
void utClearCache ()
 
virtual bool utHasMinSize () const
 
virtual int64 utGetMinSize () const
 
virtual void utSetMinSize (int64)
 
virtual bool utUpdateCacheInfo ()
 

Static Public Member Functions

static OBJ_XformCachegetCache ()
 Obtains the transform matrix cache used by all objects. More...
 
- Static Public Member Functions inherited from UT_Cache
static const UT_ValArray
< UT_Cache * > & 
utGetCacheList ()
 get the list of caches More...
 
static void setCacheAddRemoveCB (void(*callback)(void *), void *data)
 callback to be called when a cache is added or deleted. More...
 
static int64 utClearSpaceFromCaches (int64 amount)
 this method attempts to free up 'amount' bytes from all the caches. More...
 

Protected Member Functions

const char * utGetCacheName () const override
 required - return the english name for this cache. More...
 
int64 utGetCurrentSize () const override
 required - return the current cache size, in bytes More...
 
bool utHasMaxSize () const override
 optional - override if the cache has a well defined maximum size More...
 
int64 utGetMaxSize () const override
 
void utSetMaxSize (int64 size) override
 
int64 utReduceCacheSizeBy (int64 amount) override
 

Friends

class OBJ_XformCacheTag
 

Detailed Description

The OBJ_XformCache maintains a table of recently calculated transforms which describe world position and orientation of objects.

It can also watch memory usage to see what transform matrices should be removed from the table.

Definition at line 32 of file OBJ_XformCache.h.

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator
DEFAULT_CACHE_SIZE_KB 

Definition at line 52 of file OBJ_XformCache.h.

Enumerator
HIT 
MISS_VERSION 
MISS_DATA 

Definition at line 44 of file OBJ_XformCache.h.

Enumerator
MEMORY_CHECK_NEVER 
MEMORY_CHECK_ALWAYS 

Definition at line 118 of file OBJ_XformCache.h.

Enumerator
WORLD_XFORM 
LOCAL_XFORM 

Definition at line 37 of file OBJ_XformCache.h.

Constructor & Destructor Documentation

OBJ_XformCache::OBJ_XformCache ( )
OBJ_XformCache::~OBJ_XformCache ( )
override

Member Function Documentation

void OBJ_XformCache::clear ( )

Clears the cache and frees memory.

static OBJ_XformCache* OBJ_XformCache::getCache ( )
static

Obtains the transform matrix cache used by all objects.

OBJ_MemoryState OBJ_XformCache::getMemoryState ( ) const
const UT_DMatrix4& OBJ_XformCache::getXform ( int  id,
fpreal  time,
OBJ_XformType  type,
OP_VERSION  version,
OBJ_LookupStatus status 
)

querries the cache for the transform matrix INPUTS: id - the unique identification number of the operator time - the time at which the xform is applied to the object type - tranformation type version - version of parameters used to construct the xform OUTPUT: xform - on cache hit, the transform matrix, otherwise unchanged RETURNS: the status of the lookup (hit or miss)

void OBJ_XformCache::parseCommand ( CMD_Args args)

Used as the interface to objcache, which is installed in MOT_Command.C

void OBJ_XformCache::setMemoryLimit ( int64  max_memory)

Sets the new memory limit for the cache size in bytes.

bool OBJ_XformCache::setXform ( int  id,
fpreal  time,
OBJ_XformType  type,
OP_VERSION  version,
const UT_DMatrix4 xform 
)

sets the transform matrix in the cache INPUTS: id - the unique identification number of the operator time - the time at which the xform is applied to the object type - tranformation type version - version of parameters used to construct the xform RETURNS: true: if succeeded false: if failed

const char* OBJ_XformCache::utGetCacheName ( ) const
inlineoverrideprotectedvirtual

required - return the english name for this cache.

Implements UT_Cache.

Definition at line 128 of file OBJ_XformCache.h.

int64 OBJ_XformCache::utGetCurrentSize ( ) const
inlineoverrideprotectedvirtual

required - return the current cache size, in bytes

Implements UT_Cache.

Definition at line 130 of file OBJ_XformCache.h.

int64 OBJ_XformCache::utGetMaxSize ( ) const
inlineoverrideprotectedvirtual

Reimplemented from UT_Cache.

Definition at line 135 of file OBJ_XformCache.h.

bool OBJ_XformCache::utHasMaxSize ( ) const
inlineoverrideprotectedvirtual

optional - override if the cache has a well defined maximum size

Reimplemented from UT_Cache.

Definition at line 133 of file OBJ_XformCache.h.

int64 OBJ_XformCache::utReduceCacheSizeBy ( int64  amount)
overrideprotectedvirtual

required - free contents of the cache by amount bytes. Returns the amount of memory (in bytes) actually freed. This does not change the cache size

Implements UT_Cache.

void OBJ_XformCache::utSetMaxSize ( int64  size)
overrideprotectedvirtual

Reimplemented from UT_Cache.

Friends And Related Function Documentation

friend class OBJ_XformCacheTag
friend

Definition at line 163 of file OBJ_XformCache.h.


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