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_Rect.h>
19 #include <UT/UT_UniquePtr.h>
20 #include <UT/UT_VectorTypes.h>
21 #include <SYS/SYS_Types.h>
22 
23 
24 class RE_Geometry;
25 class RE_Render;
26 class RE_VertexArray;
27 template <typename T> class UT_Array;
28 class UT_TokenString;
29 
30 class re_BoxPickData;
31 
32 
34 {
35 public:
36  RE_PickBuffer();
37  ~RE_PickBuffer();
38 
39  bool resize(RE_Render *r, int w, int h);
40  void invalidate();
41  void startRender(RE_Render *r);
42  void drawToBuffer(RE_Render *r,
44  int colorbufnum = 0);
45  void drawToAllBuffers(RE_Render *r);
46  void endRender(RE_Render *r, UT_TokenString *&new_hash);
47 
48  // The picks returned by this method are sequential in pick_dist in that
49  // if a pick_dist of d returns a sequence of n picks, these will also be
50  // the first n picks in the sequence for a pick_dist of d + 1.
51  //
52  // The sample_counts_by_dist parameter is provided to aid in determining
53  // which of the returned picks would also be picks for distances less
54  // than pick_dist. If a nonzero pointer is supplied, it will be set to
55  // point to an array such that the first (*sample_counts_by_dist)[i] of
56  // the returned picks would also be picks for a pick_dist of i, for i
57  // in [0 .. RE_MAX_PICK_DIST]. This array pointer will only be set if
58  // this method returns a nonzero count, and should *NOT* be deleted.
59  //
60  // The sample_offsets parameter is provided to allow querying the pixel
61  // offset of a given pick index in the picks returned by this method
62  // using the helper getPickSampleOffset() method. This array pointer
63  // will only be set if this method returns a nonzero count, and should
64  // *NOT* be deleted.
65  int getPicks(RE_Render *r,
66  int x, int y, int pick_dist,
67  RE_VertexArray *&high_array,
68  RE_VertexArray *&low_array,
69  RE_VertexArray *&z_array,
70  const UT_IntArray **sample_counts_by_dist
71  = nullptr,
72  const UT_Array<int16> **sample_offsets
73  = nullptr);
74 
75  int getPicks(RE_Render *r,
76  const UT_DimRect &area,
77  uint8 *texture,
78  UT_Vector3iArray &pick_high,
79  UT_Vector3iArray &pick_low);
80  const UT_SharedPtr<RE_Texture> &getPickHighTexture();
81  const UT_SharedPtr<RE_Texture> &getPickLowTexture();
82  const UT_SharedPtr<RE_Texture> &getZTexture();
83 
84  // Helper method for correctly using the sample_offsets array obtained
85  // from getPicks().
86  UT_Vector2i getPickSampleOffset(
87  const UT_Array<int16> *sample_offsets,
88  exint sample_index) const;
89 
90  bool initialized() const;
91  bool checkHash(const UT_TokenString *hash) const;
92 
93  void saveBuffers(RE_Render *r,
94  const char *path,
95  const char *prefix,
96  bool mid_render) const;
97 
98 protected:
99  int normalPickFetch(RE_Render *r,
100  const UT_DimRect &area,
101  uint8 *texture,
102  UT_Vector3iArray &pick_high,
103  UT_Vector3iArray &pick_low);
104  int slowPickFetch(RE_Render *r,
105  const UT_DimRect &area,
106  uint8 *texture,
107  UT_Vector3iArray &pick_high,
108  UT_Vector3iArray &pick_low);
109  RE_FBOStatus create(RE_Render *r, int w, int h);
110  void destroy();
111 
121  mutable int mySaveCount;
122 };
123 
124 #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:53
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:44
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_SharedPtr< RE_OGLFramebuffer > myBuffer
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