3ds Max C++ API Reference
IPhysicalCamera::RenderTransformEvaluationGuard Class Reference

A guard class which enables a physical camera INode to evaluate itself for ray-traced rendering (as opposed to viewport rendering). More...

#include <IPhysicalCamera.h>

+ Inheritance diagram for IPhysicalCamera::RenderTransformEvaluationGuard:

Public Member Functions

 RenderTransformEvaluationGuard (INode *const node, const TimeValue t)
 The constructor enables an option, on the physical camera, which further calls to Object::Eval() ignore the tilt/shift feature. More...
 
 ~RenderTransformEvaluationGuard ()
 The destructor restores the previous state of the flag which disables the tilt/shift feature. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

A guard class which enables a physical camera INode to evaluate itself for ray-traced rendering (as opposed to viewport rendering).

In order to render viewports (more or less) correctly, the physical camera overrides Object::Eval() to return a object-space transform matrix which approximates the lens tilt/shift effect. Because this approximation fails in some cases, a ray-traced renderer should implement its own version of the tilt/shift effect. To do this, the renderer must disable the tilt/shift approximation from the evaluation of the transform matrix; it does so by instantiating this guard class wherever a camera INode is evaluated (e.g. through INode::EvalWorldState() or INode::GetObjTMAfterWSM()).

Remarks
This class follows the guard implementation pattern, which performs all required work in the constructor and destructor.

Constructor & Destructor Documentation

◆ RenderTransformEvaluationGuard()

RenderTransformEvaluationGuard ( INode *const  node,
const TimeValue  t 
)
inline

The constructor enables an option, on the physical camera, which further calls to Object::Eval() ignore the tilt/shift feature.

Remarks
This constructor also invalidates the node's object cache to ensure that further evaluations will behave correctly.
Parameters
nodeThe node which potentially evaluates to an IPhysicalCamera object. It is OK to pass a null pointer, or a node which refers to an object that is not an IPhysicalCamera.
tThe time at which the object is evaluated. While this call is not dependent on any animated parameters, it is preferable to pass the time value at which the renderer will be evaluating the camera, for efficiency purposes.
50  :m_node(node),
51  m_timeValue(t),
52  m_previous_value(false)
53 {
54  if(m_node != nullptr)
55  {
56  // Evaluate the node
57  const ObjectState &os = m_node->EvalWorldState(m_timeValue);
58 
59  // See if it's a physical camera
60  IPhysicalCamera* const physical_camera = dynamic_cast<IPhysicalCamera*>(os.obj);
61  if(physical_camera != nullptr)
62  {
63  // Enable future evaluation of render transform
64  m_previous_value = physical_camera->SetEvaluatingRenderTransform(true);
65 
66  if(!m_previous_value)
67  {
68  // Invalidate object cache to force object transform to be re-evaluated
70  // Re-evaluate world state in case caller holds a reference to the node's ObjectState - make sure that ObjectState is re-initialized
71  m_node->EvalWorldState(m_timeValue);
72  }
73  }
74  }
75 }
virtual const ObjectState & EvalWorldState(TimeValue time, BOOL evalHidden=TRUE)=0
virtual void InvalidateObCache(INode *node)=0
The ObjectState is the structure that flows up the geometry pipeline.
Definition: object.h:284
Object * obj
Pointer to the object in the pipeline.
Definition: object.h:295
CoreExport Interface7 * GetCOREInterface7()

◆ ~RenderTransformEvaluationGuard()

The destructor restores the previous state of the flag which disables the tilt/shift feature.

Remarks
This destructor also invalidates the node's object cache to ensure that further evaluations will behave correctly.
78 {
79  if(m_node != nullptr)
80  {
81  // Evaluate the node
82  const ObjectState &os = m_node->EvalWorldState(m_timeValue);
83 
84  // See if it's a physical camera
85  IPhysicalCamera* const physical_camera = dynamic_cast<IPhysicalCamera*>(os.obj);
86  if(physical_camera != nullptr)
87  {
88  // Restore the previous flag value
89  physical_camera->SetEvaluatingRenderTransform(m_previous_value);
90 
91  // Invalidate world state cache to force object transform to be re-evaluated
92  if(!m_previous_value)
93  {
94  // Invalidate object cache to force object transform to be re-evaluated
96  // Re-evaluate world state in case caller holds a reference to the node's ObjectState - make sure that ObjectState is re-initialized
97  m_node->EvalWorldState(m_timeValue);
98  }
99  }
100  }
101 }