HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_PickBuffer.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Render Library (C++)
7  *
8  * COMMENTS:
9  * Holds a frame buffer object that can receive pick information.
10  */
11 
12 #ifndef __RE_PickBuffer_h__
13 #define __RE_PickBuffer_h__
14 
15 #include "RE_API.h"
16 #include "RE_Texture.h"
17 #include "RE_OGLFramebuffer.h"
18 #include <UT/UT_NonCopyable.h>
19 #include <UT/UT_Rect.h>
20 #include <UT/UT_UniquePtr.h>
21 #include <UT/UT_VectorTypes.h>
22 #include <SYS/SYS_Types.h>
23 
24 
25 class RE_Geometry;
26 class RE_Render;
27 class RE_VertexArray;
28 template <typename T> class UT_Array;
29 class UT_TokenString;
30 
31 class re_BoxPickData;
32 
33 
35 {
36 public:
37  RE_PickBuffer();
38  ~RE_PickBuffer();
39 
41 
42  bool resize(RE_Render *r, int w, int h);
43  void invalidate();
44  void startRender(RE_Render *r);
45  void drawToBuffer(RE_Render *r,
47  int colorbufnum = 0);
48  void drawToAllBuffers(RE_Render *r);
49  void endRender(RE_Render *r, UT_TokenString *&new_hash);
50 
51  // The picks returned by this method are sequential in pick_dist in that
52  // if a pick_dist of d returns a sequence of n picks, these will also be
53  // the first n picks in the sequence for a pick_dist of d + 1.
54  //
55  // The sample_counts_by_dist parameter is provided to aid in determining
56  // which of the returned picks would also be picks for distances less
57  // than pick_dist. If a nonzero pointer is supplied, it will be set to
58  // point to an array such that the first (*sample_counts_by_dist)[i] of
59  // the returned picks would also be picks for a pick_dist of i, for i
60  // in [0 .. RE_MAX_PICK_DIST]. This array pointer will only be set if
61  // this method returns a nonzero count, and should *NOT* be deleted.
62  //
63  // The sample_offsets parameter is provided to allow querying the pixel
64  // offset of a given pick index in the picks returned by this method
65  // using the helper getPickSampleOffset() method. This array pointer
66  // will only be set if this method returns a nonzero count, and should
67  // *NOT* be deleted.
68  int getPicks(RE_Render *r,
69  int x, int y, int pick_dist,
70  RE_VertexArray *&high_array,
71  RE_VertexArray *&low_array,
72  RE_VertexArray *&z_array,
73  const UT_IntArray **sample_counts_by_dist
74  = nullptr,
75  const UT_Array<int16> **sample_offsets
76  = nullptr);
77 
78  int getPicks(RE_Render *r,
79  const UT_DimRect &area,
80  uint8 *texture,
81  UT_Vector3iArray &pick_high,
82  UT_Vector3iArray &pick_low);
83  const UT_SharedPtr<RE_Texture> &getPickHighTexture();
84  const UT_SharedPtr<RE_Texture> &getPickLowTexture();
85  const UT_SharedPtr<RE_Texture> &getZTexture();
86 
87  // Helper method for correctly using the sample_offsets array obtained
88  // from getPicks().
89  UT_Vector2i getPickSampleOffset(
90  const UT_Array<int16> *sample_offsets,
91  exint sample_index) const;
92 
93  bool initialized() const;
94  bool checkHash(const UT_TokenString *hash) const;
95 
96  void saveBuffers(RE_Render *r,
97  const char *path,
98  const char *prefix,
99  bool mid_render) const;
100 
101 protected:
102  int normalPickFetch(RE_Render *r,
103  const UT_DimRect &area,
104  uint8 *texture,
105  UT_Vector3iArray &pick_high,
106  UT_Vector3iArray &pick_low);
107  int slowPickFetch(RE_Render *r,
108  const UT_DimRect &area,
109  uint8 *texture,
110  UT_Vector3iArray &pick_high,
111  UT_Vector3iArray &pick_low);
112  RE_FBOStatus create(RE_Render *r, int w, int h);
113  void destroy();
114 
124  mutable int mySaveCount;
125 };
126 
127 #endif
UT_SharedPtr< RE_Texture > myZTexture
#define RE_API
Definition: RE_API.h:10
UT_SharedPtr< RE_Texture > myHighIdTexture
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:52
int64 exint
Definition: SYS_Types.h:125
GLint y
Definition: glcorearb.h:103
unsigned char uint8
Definition: SYS_Types.h:36
RE_FBOStatus
RE_GPUType
Definition: RE_Types.h:52
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_SharedPtr< RE_OGLFramebuffer > myBuffer
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
RE_BufferAttachment
UT_SharedPtr< RE_Geometry > mySinglePickGeometry
GLint GLenum GLint x
Definition: glcorearb.h:409
UT_SharedPtr< RE_Texture > myLowIdTexture
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
ImageBuf OIIO_API resize(const ImageBuf &src, string_view filtername="", float filterwidth=0.0f, ROI roi={}, int nthreads=0)
UT_SharedPtr< re_BoxPickData > myBoxPickData
UT_TokenString * myBufferHash
GLuint texture
Definition: glcorearb.h:415
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLboolean r
Definition: glcorearb.h:1222
RE_GPUType myDepthFormat
GA_API const UT_StringHolder area