HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DM_VPortAgent.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: DM_VPortAgent.h ( DM Library, C++)
7  *
8  * COMMENTS:
9  * DM_VPortAgent is the class for the 2D & 3D viewport agents.
10  * Viewport agents encapsulate the viewport functionality that is
11  * specific to a particular kind of viewport, such as
12  * rendering. There is one agent for each viewport.
13  */
14 
15 #ifndef __DM_VPortAgent__
16 #define __DM_VPortAgent__
17 
18 #include "DM_API.h"
19 #include "DM_Defines.h"
20 #include "DM_GeoDetail.h"
21 #include "DM_ViewportType.h"
22 
23 #include <UI/UI_Object.h>
24 #include <UI/UI_XPtr.h>
25 #include <OP/OP_Bundle.h>
26 #include <GEO/GEO_PrimTypeCompat.h>
27 #include <GR/GR_Defines.h>
28 #include <GUI/GUI_RenderCommon.h>
29 #include <GUI/GUI_ViewParameter.h>
30 #include <GUI/GUI_ViewState.h>
31 #include <RE/RE_Texture.h>
32 #include <RE/RE_LightList.h>
33 #include <RE/RE_TimerQuery.h>
34 #include <RE/RE_PickBuffer.h>
35 #include <RE/RE_OGLFramebuffer.h>
36 #include <PXL/PXL_Lookup.h>
37 #include <UT/UT_VectorTypes.h>
38 
39 class RE_RenderWait;
40 class UI_Event;
41 class OBJ_Ambient;
42 class GR_PickRecord;
43 class GUI_DisplayOption;
44 class GUI_GeoRender;
45 class GUI_SceneLook;
46 class GUI_ViewState;
47 class DM_FloorInterface;
48 class DM_PostEffects;
49 class DM_RenderHighQuality;
50 class DM_SceneManager;
51 class DM_SnapBuffer;
52 class DM_Viewport;
53 class DM_ViewportHooks;
54 
56 {
57 public:
58  DM_VPortAgent(DM_SceneManager &app,
59  DM_Viewport *display,
60  GUI_ViewState *view,
62  ~DM_VPortAgent() override;
63 
64  /// Each viewport has a unique integer id used to differentiate them.
65  int getUniqueId() const;
66 
67  /// Compute bounding box of the scene.
68  int getBoundingBox(UT_BoundingBox &bbox,
69  const UT_Matrix3R *rot,
70  bool non_templated_only,
71  const DM_Viewport &viewport) const;
72 
73  /// Called by DM_Viewport to initialize and retire the viewport agent
74  /// when opening and closing. Treat as private.
75  void setupViewport();
76  void cleanupViewport();
77 
78  void refresh() const;
79 
80  /// The projection type of this viewport
81  DM_ViewportType getViewType() const { return myType; }
82 
83  /// For ortho viewports, the projection type (top, front, right, etc)
84  GUI_ViewParameter::axis getHomeAxis() const;
85 
86  /// Projection type, ortho or perspective
87  int isOrtho() const;
88 
89  /// Returns true if user interaction is occuring (drag, tumble, XCF).
90  bool isActiveRender() const;
91 
92  /// Returns true if this is rendering LOPs, and false if Obj,SOPs or DOPs.
93  bool isLopsView() const;
94 
95  /// The view state contains transform, projection and display options
96  const GUI_ViewState &getViewStateRef() const;
97  GUI_ViewState &getViewStateRef();
98 
99  /// Given a look id, and possibly a GUI_DetailList, find the GUI_DetailLook
100  /// with the supplied id.
101  GUI_DetailLookPtr getDetailLook(int look_id, const GUI_DetailList *geos);
102  GUI_DetailLookPtr getDetailLook(int node_id) const;
103 
104  /// Fetch the detail of the current SOP or POP
105  const GUI_DetailLook*currentDetail() const;
106  GUI_DetailLook *currentDetail();
107 
108  // Return the op node the viewport is looking through (camera or light)
109  OP_Node *currentCamera() const;
110 
111  /// turn on/off the background elements
112  void drawBackground(bool draw);
113 
114  /// Called when loading a new hip file or File>New
115  void resetForNew();
116 
117  /// handle a change in our display options
118  void handleDisplayOptionEvent(UI_Event *e);
119 
120  /// handle a change in our view parameters
121  void handleViewParameterEvent(UI_Event *e);
122 
123  /// render all elements in this viewport
124  void doRender(RE_Render *r, int x, int y);
125 
126  /// render any transient overlay elements in the viewport
127  void overlayRender(RE_Render *r, int x, int y);
128 
129  /// render all handles present in the viewport
130  void renderHandles(RE_Render *r, int x, int y,
131  unsigned mask);
132 
133  /// Change the type of the viewport to a different projection or 2D/3D
134  void changeType(UI_Object *by, DM_ViewportType new_type);
135 
136  /// Called when the viewport closes, but is not deleted (such as a pane tab
137  /// switch).
138  void close();
139 
140  /// Request a deferred redraw.
141  void requestDraw() { myRedrawNotify.changed(nullptr); }
142 
143  /// @brief Access the beauty pass textures
144  /// Get a texture containing the color or depth of the beauty pass buffer.
145  /// This texture is always single-sampled.
146  RE_Texture *getBeautyPassTexture(RE_Render *r,
147  bool resolve_aa = true) const;
148  RE_Texture *getBeautyPassDepthTexture(RE_Render *r,
149  bool resolve_aa = true) const;
150 
151  /// copy the beauty pass to 'dst_texture'.
152  bool copyBeautyToTexture(RE_Render *r,
153  UT_DimRect src_area,
154  RE_Texture *dst_texture,
155  int dst_layer) const;
156 
157  /// Returns the LUT for the beauty pass, if any.
158  PXL_Lookup *getBeautyLUT();
159  TIL_Raster *getBeautyPassImage(RE_Render *r);
160  TIL_Raster *getBeautyPassDepthImage(RE_Render *r);
161  bool getBeautyPassHDR() const;
162  void setBeautyPassConsolidate(bool con);
163 
164  /// ensure all geometry is up to date before a redraw, and cleanup after
165  void preSetupGeometry(RE_Render *r);
166  void postCleanupGeometry(RE_Render *r);
167  void setupGeometry(RE_Render *r);
168  void cleanupGeometry(RE_Render *r);
169  void fastSetupGeometry(RE_Render *r);
170 
171  /// returns a single pick result from the x,y mouse coords. The pick buffer
172  /// must be rendered first. Returns false if nothing was picked.
173  bool singlePickObject(RE_Render *r, int x, int y,
175  const GR_ObjectPickFlags &pick_flags,
176  fpreal *depth,
177  const GUI_DetailList *geos);
178 
179  /// Check for a pick on a handle. Returns true if a handle was picked.
180  bool singlePickHandle(RE_Render *r, int x, int y,
182  fpreal *depth);
183 
184  /// @brief Area select objects, possibly with a matte.
185  /// returns a list of object IDs for those objects picked. This does not
186  /// pick handles or SOP geometry. The return value is the length of the pick
187  /// list.
188  int boxPickObject(RE_Render *r,
189  const UT_DimRect &area,
190  uint8 *texture,
191  UT_Array<GR_PickRecord> &pick_records,
192  bool visible_only,
193  bool wholy_contained,
194  const GUI_DetailList *geos);
195 
196  /// @brief Single select a geomerty element.
197  /// Returns a single pick result for components in objects 'geos'.
198  bool singlePickComponent(RE_Render *r,
199  int x, int y,
201  unsigned pickmask,
203  fpreal *depth,
204  const GUI_DetailList *geos,
205  bool enable_occlusion);
206  /// Box, lasso or paint select components.
207  int boxPickComponent(RE_Render *r,
208  const UT_DimRect &area,
209  uint8 *texture,
210  UT_Array<GR_PickRecord> &pick_records,
211  bool sort_records,
212  unsigned pickmask,
214  bool visible_only,
215  bool contained,
216  bool interactive,
217  const GUI_DetailList *geos);
218  int componentPickRender(RE_Render *r,
219  unsigned int pickmask,
220  unsigned int xray_pickmask,
222  const GUI_DetailList *geos,
223  GR_PickStyle pickstyle,
224  bool invert_mask,
225  UT_Array<GR_PickRecord> *pick_rec);
226 
227  /// @brief Single select a geometry element to snap to.
228  /// Returns a single snap result for components in objects 'geos'.
229  bool singleSnapComponent(RE_Render *r,
230  int x, int y,
231  bool hide_selected, bool enable_occlusion,
232  bool do_current,
233  bool do_xray, bool do_guides,
234  bool extend_floor,
236  UT_Vector2i *result_offset,
237  UT_Array<GR_PickRecord> &near_results,
238  unsigned pickmask, int gravity,
240  const GUI_DetailList *geos=NULL);
241 
242  /// @brief Single select a peanut element to snap to.
243  /// Returns a single snap result for peanuts.
244  bool singleSnapPeanut(RE_Render *r,
245  int x, int y,
246  bool hide_selected, bool enable_occlusion,
247  bool do_xray, bool do_guides,
248  bool extend_floor,
250  UT_Vector2i *result_offset,
251  unsigned pickmask,
253  const GUI_DetailList *geos=NULL);
254 
255  // Currently only for scene graph view.
256  bool snapGeometry(RE_Render *r,
257  int x, int y,
258  int pnt_rad, int edge_rad, int face_rad,
259  bool occlusion,
260  bool orient_normals,
261  DM_SnapSelection snap_sel,
262  UT_Vector3D &p,
263  UT_Vector3D &n,
264  int64 serial);
265 
266  /// Call to manually invalidate any cached pick/snap buffers when the
267  /// automatic detection is insufficient.
268  void invalidatePickBuffers();
269 
270  /// Box, lasso or paint select components.
271  /// Render all geometry in the viewport using render mode 'render_type'.
272  GUI_RenderPassFlags renderGeometry(RE_Render *r,
273  GR_RenderMode render_type,
274  GR_ShadingPass shade_pass,
275  GR_AlphaPass apass,
276  OP_Bundle *visible_objs = NULL,
278 
279  /// @brief Draw geometry decorations and markers
280  /// Render all decorations. If 'hover_decorations' is true, only the
281  /// locate-style decorations will be drawn.
282  void renderDecorations(RE_Render *r,
283  GUI_DisplayOption *dispopt,
284  bool hover_decorations);
285 
286  /// Render geometry corresponding to the OP_Nodes is the passed list.
287  GUI_RenderPassFlags renderSomeGeometry(RE_Render *r, int x, int y,
288  const UT_Array<OP_Node*> &nodes,
289  const UT_IntArray *detail_indexes,
290  GR_RenderMode render_type,
291  GR_ShadingPass shade_pass,
292  GR_AlphaPass apass,
293  bool do_geometry_setup);
294 
295  /// Render a single geometry using render mode 'render_type'.
296  GUI_RenderPassFlags renderSingleGeo(RE_Render *r,
297  GUI_GeoRender *gr,
298  GR_RenderMode render_type,
299  GR_ShadingPass shading_pass,
300  GR_AlphaPass ap,
301  bool init_lights,
302  bool treat_uv_viewport_as_3d = false);
303 
304  /// Our floor or construction plane.
305  void renderFloor(RE_Render *r, int x, int y);
306  /// Render construction plane in overlayRender.
307  void overlayRenderFloor(RE_Render *r, int x, int y);
308 
309  const DM_FloorInterface *getFloorInterface() const
310  { return myFloorInterface; }
311  DM_FloorInterface *getFloorInterface() { return myFloorInterface; }
312 
313  /// Interface to viewport hooks (render and mouse)
314  DM_ViewportHooks &hooks() const { return *myViewportHooks; }
315 
316  bool needsOverlayRender() const
317  { return myNeedsOverlayRender; }
318 
319  /// Methods to process mouse movement
320  /// @{
321  bool hasLocates();
322  void handleLocateEvent(UI_Event *e);
323  /// @}
324 
325  /// @brief Access displayed objects in the viewport
326  /// Return a handle to an object displayed in the viewport. Do not cache
327  /// these over several redraws, as they may become invalid. get*Object()'s
328  /// index parameter can be 0 to getNum*Objects()-1.
329  /// @{
330  int getNumOpaqueObjects() const;
331  DM_GeoDetail getOpaqueObject(int index) const;
332 
333  int getNumTransparentObjects() const;
334  DM_GeoDetail getTransparentObject(int index) const;
335 
336  int getNumUnlitObjects() const;
337  DM_GeoDetail getUnlitObject(int index) const;
338 
339  int getNumXRayObjects() const;
340  DM_GeoDetail getXRayObject(int index) const;
341  /// @}
342 
343  /// Returns the current detail within the object, when at SOP/POP/DOP level.
344  DM_GeoDetail getCurrentDetail() const;
345 
346  void initGPUTimers(RE_Render *r);
347  void collectGPUTimers(RE_Render *r);
348 
349  GUI_RotoView getRotoViewType();
350 
351  void markGeoSetup(bool setup,
352  DM_Viewport *setup_port = NULL);
353  bool isGeoSetup() const { return mySetupFlag; }
354 
355  // All lights in the scene, for the material render codepath.
356  void setGlobalLightArray(const UT_Array<OBJ_Ambient *> &l);
357  void setGlobalLightArray(const UT_ValArray<RE_Light*> &l);
358 
359  // Get and set lighting information.
360  bool setupLights(RE_Render *r, GUI_DisplayOption *opt);
361  void cleanupLights(RE_Render *r);
362  RE_LightList *getLightList() { return &myLightList; }
363  const RE_LightList *getLightList() const { return &myLightList; }
364 
366  { return myMaterialLights; }
367 
368  GR_LightingPass getLightingPass() const { return myLightingPass; }
369  void setLightingPass(GR_LightingPass p) { myLightingPass=p;}
370 
371  // Returns the approximate memory usage of the viewport at the current size
372  // given hdr on/off, high quality lighting on/off, transparency > low,
373  // and aa at 1,2,4 or 8x.
374  int64 getFramebufferUsageKB(bool hdr, bool hql, bool trans,
375  int aa);
376 
377  // using zt[0] / (Z + zt[1]) will transform zbuffer values into viewspace Z
378  // If light is specified, then the shadowmap range of that light is computed
379  void getZBufferTransform(float zt[2],RE_Light *light=NULL);
380 
381  // Handle a change in which geometry is displayed.
382  // For keeping track of what type of UVs to show in UV mode.
383  void handleNewGeometryEvent(UI_Event *e);
384  void updateAttributeOptions(const GU_DetailHandle &gdh);
385 
386  // ---------------------------------------------------------------------
387  // the following methods should be treated as private to DM.
388 
389  /// Methods for starting and stopping events
390  /// in the old performance monitor.
391  void startPerfMonTimer(RE_Render *r,
392  RE_GPUTimer &timer,
393  const char *msg) const;
394  void stopPerfMonTimer(RE_Render *r,
395  RE_GPUTimer &timer) const;
396 
397  // setup proper winding and culling, returning a set of flags to use for
398  // the cleanup method.
399  int setupBackfaceAndWinding(RE_Render *r,
400  const GUI_DisplayOption *opts);
401  void cleanupBackfaceAndWinding(RE_Render *r,
402  int setup_flags);
403 
404  // resolve the AA Z buffer to a single sample, taking the further sample
405  bool resolveDepthBuffer(RE_Render *r,
406  RE_Texture *aa_depth_tex,
407  RE_Texture *depth_tex) const;
408 
409  int64 getSceneVersion(fpreal t, bool shadow, bool &timedep);
410 
411  // access to parent viewport
412  const DM_Viewport *getDisplay() const { return myDisplay; }
413  DM_Viewport *getDisplay() { return myDisplay; }
414 
415  // for transparency
416  int getTransparencyLayers(RE_Render *r,
417  const GUI_DisplayOption *disp);
418  void prepareStencilRouting(RE_Render *r, int nsamples);
419  void prepareABufferFront(RE_Render *r, int nsamples);
420 
421  void updateTimeDependentLook(fpreal t);
422 
423  bool isToolbarLinked() const; // see .C file note
424 
425  const GUI_DetailPtrList &getDetails() const;
426  const GUI_DetailPtrList &getDetails();
427 
428  void setupViewUniforms(RE_Render *r);
429  void cleanupViewUniforms(RE_Render *r);
430 
431  // Looks through the lights for an environment map
432  void applyEnvMapOverride(RE_Render *r) const;
433 
434  // For DM_RenderHighQuality.
435  bool needsToDrawFloor() const
436  { return myDrawFloorTransientFlag; }
437  void initFogVolume(RE_Render *r,
438  DM_Viewport *vport,
439  GUI_FogMode fog,
440  const RE_Texture *zdepth) const;
441  RE_Texture *getFogVolumeTexture() const;
442  RE_Texture *getRandomDitherTexture(RE_Render *r);
443 
444  const DM_SceneManager &modeler() const
445  { return mySceneManager; }
446 
447  void renderBackgroundImage(RE_Render *r);
448  void renderForegroundImage(RE_Render *r);
449 
450  void resolveBeautyColorPass(RE_Render *r,
451  RE_Texture *aa_color,
452  RE_Texture *aa_depth,
453  RE_Texture *aa_nml) const;
454 protected:
455  friend class dm_SetupTask;
456 
457 private:
458 
459  DM_SceneManager &modeler()
460  { return mySceneManager; }
461 
462  const GUI_SceneLook *getLook() const { return mySceneLook.get(); }
463  GUI_SceneLook *getLook() { return mySceneLook.get(); }
464 
465  bool shouldDisplayObject(const DM_Viewport &vport,
466  GUI_DetailLook *look,
467  OBJ_Node *node);
468 
469  bool shouldVisualizeObject(const DM_Viewport &vport,
470  GUI_DetailLook *look,
471  OBJ_Node *node);
472 
473  bool shouldShowComponentSelections(const GUI_DetailLook &look,
474  const GUI_DisplayOption &d) const;
475 
476  enum DM_BufferBlend
477  {
478  ACCUM_ADD,
479  ACCUM_REPLACE,
480  ACCUM_ALPHA_BLEND
481  };
482 
483  // prints a message in the viewer (centrally justified) on a given line
484  void renderMessage( RE_Render *ren, int x, int y,
485  const char* msg, int line );
486  // renders true viewer name
487  void doRenderCurrentName(RE_Render *r, int x, int y);
488  // renders the snapshot label
489  void doRenderSnapshotName(RE_Render *r, int x, int y);
490 
491  // prints a message in the viewer for camera (central, bottom justified)
492  void renderCameraMessage( RE_Render *ren, int x, int y,
493  const char* msg);
494 
495  // Render a mask over the parts of the viewport outside of the view
496  // subregion.
497  void renderViewMask(RE_Render *r, int x, int y);
498 
499  bool resizeBeautyPassBuffer(RE_Render *r,
500  int width, int height,
501  bool hdr, bool needs_aa);
502  void destroyBeautyPassBuffer();
503  RE_OGLFramebuffer *getBeautyPassBuffer(bool allow_aa);
504 
505  // initializes the view and projection to a 1:1 pixel transform.
506  void pushIdentityOrthoView(RE_Render *r);
507  void popIdentityOrthoView(RE_Render *r);
508 
509  // Render the viewport name.
510  void doRenderName(RE_Render *r, int x, int y,
511  bool snapshot_name = false);
512  // Render the current state information.
513  void doRenderStateStatus(RE_Render *r);
514  // Render a mask over the parts of the viewport outside of the view
515  // subregion.
516  void doRenderViewMask(RE_Render *r, int x, int y);
517 
518  // Draw the view overview gadget.
519  void doRenderViewOverview(RE_Render *r, int x, int y);
520 
521  // Common utility methods to setup lights and the z buffer.
522  void setupForRender(RE_Render &ren,
523  bool allow_smooth = true);
524  void cleanupAfterRender(RE_Render &ren);
525 
526 
527  void setGammaPass(bool b) { myGammaPass = b?1:0; }
528 
529  void doRenderNoHookUnlitObjects(RE_Render *r, int x, int y,
530  bool xray_pass);
531  void doRenderUnlitObjects(RE_Render *r, int x, int y);
532 
533  // Render the camera's mask (bars and anything else inside the mask)
534  void doRenderMask(RE_Render *r, int, int);
535 
536  // Selection ouylines for lop/obj selection
537  void doRenderSelectionOutline(RE_Render *r);
538  void destroySelectionBuffer();
539 
540  void startBeautyPass(RE_Render *r, bool allow_aa=true);
541  void endBeautyPass(RE_Render *r, bool allow_aa=true);
542  bool isBeautyPassAA(bool allow_aa = true);
543 
544  // helper methods for setting up stereo passes
545  void setupStereo3d(RE_Render *r);
546  void setupStereoVR(RE_Render *r);
547  void cleanupStereo3d(RE_Render *r);
548  void interruptStereo(RE_Render *r);
549  void resumeStereo(RE_Render *r);
550  void setupStereo3dForLeftCamera(RE_Render *r,
551  bool uniforms_for_3d);
552  void setupStereo3dForRightCamera(RE_Render *r,
553  bool uniforms_for_3d);
554  void updateStereoViewUniforms(RE_Render *r, bool left);
555  void assignStereoLeft(RE_Render *r,
556  const GUI_ViewState::GUI_ViewType vt);
557  void assignStereoRight(RE_Render *r,
558  const GUI_ViewState::GUI_ViewType vt);
559  void assignStereoTop(RE_Render *r,
560  const GUI_ViewState::GUI_ViewType vt);
561  void assignStereoBottom(RE_Render *r,
562  const GUI_ViewState::GUI_ViewType vt);
563 
564  bool setupTransparentBuffers(RE_Render *r, int hdr);
565  void destroyTransparentBuffers();
566 
567  void renderViewport(RE_Render *r, int x, int y);
568  void renderSceneView(RE_Render *r, int x, int y);
569 
570  // Render the transparent bars defined by the camera's mask parameters
571  void renderCameraMask(RE_Render *r);
572 
573  // Render the object that goes on top of the camera mask
574  void renderCameraMaskOverlay(RE_Render *, int, int);
575 
576  void renderTransparentGeometry(
577  RE_Render *r,
578  GUI_DisplayOption *dispopt);
579  bool renderHQTransparencyPass(
580  RE_Render *r, int x, int y,
581  GUI_DisplayOption *dispopt,
582  const UT_Array<GUI_DetailLook *> *geos = NULL,
583  bool for_xray = false);
584  bool setupHQTransparentBuffers(RE_Render *r, int nsamples,
585  bool hdr);
586  void destroyHQTransparentBuffers();
587 
588  void initStencilABuffer(RE_Render *r, int nsamples);
589 
590  bool setupUnlitAlphaBuffer(RE_Render *r, bool zbuf);
591  void destroyUnlitAlphaBuffer();
592 
593  // Geometry pick code
594  bool createPickBuffer(RE_Render *r);
595  bool renderPickBuffer(RE_Render *r,
596  bool object_pick,
597  bool enable_occlusion,
598  unsigned int pickmask,
600  const GUI_DetailList *geos,
601  const GR_ObjectPickFlags &pick_flags);
602 
603  // Query the pick buffer. Returns true on a hit.
604  // allow_geo - allow geometry picks (either obj or component
605  // depending on geo_is_object)
606  // allow_handle - allow handle picks
607  // geo_is_object - geometry records are objects instead of
608  // components
609  // geo_ignore_depth - avoid scanning samples looking for a closer
610  // hit (only when !geo_is_object)
611  // geo_prioritize - scan samples looking for a higher priority
612  // component pick (only when !geo_is_object)
613  // floor_prioritize - scan samples looking for a higher priority
614  // floor component pick (only when allow_handle
615  // and does not differentiate between different
616  // floors)
617  // overlap_dist - the distance at which to consider picks to
618  // be essentially overlapping and employ some
619  // heuristics to pick the best one
620  bool pickFromBuffer(RE_Render *r,
621  RE_PickBuffer *pick_buffer,
622  int x, int y,
623  bool allow_geo,
624  bool allow_handle,
625  bool geo_is_object,
626  bool geo_ignore_depth,
627  bool geo_prioritize,
628  bool floor_prioritize,
629  int pick_dist,
630  int overlap_dist,
632  UT_Array<GR_PickRecord> *results,
633  UT_Vector2i *result_offset,
634  fpreal *depth,
635  const GUI_DetailList *geos);
636 
637  int filterPickData(int32 *pick_base_data,
638  int32 *pick_component_data,
639  int npicks,
640  UT_Array<GR_PickRecord> &pick_records);
641  int subtractPickData(const UT_Vector3iArray &base,
642  const UT_Vector3iArray &comp,
643  const UT_Array<GR_PickRecord> &outside,
644  UT_Array<GR_PickRecord> &results);
645  void objectPickRender(RE_Render *r,
646  unsigned int pickmask,
648  const GUI_DetailList *geos,
649  const GR_ObjectPickFlags &pick_flags);
650  void doObjectBoxPick(RE_Render *r,
651  const UT_DimRect &area,
652  UT_Array<GR_PickRecord> &pick_records,
653  bool visible_only,
654  bool invert_mask,
655  bool use_texture,
656  bool clip_edges,
657  const GUI_DetailList *geos);
658 
659  int boxPickVisibleComponent(RE_Render *r,
660  const UT_DimRect &area,
661  uint8 *texture,
662  UT_Array<GR_PickRecord> &pick_records,
663  unsigned pickmask,
665  const GUI_DetailList *geos,
666  bool contained);
667  int boxPickFrustumComponent(RE_Render *r,
668  const UT_DimRect &area,
669  uint8 *texture,
670  UT_Array<GR_PickRecord> &pick_records,
671  unsigned pickmask,
673  const GUI_DetailList *geos,
674  bool visible_only,
675  bool contained);
676  int boxPickComponentGL42(RE_Render *r,
677  const UT_DimRect &area,
678  uint8 *texture,
679  UT_Array<GR_PickRecord> &pick_records,
680  unsigned pickmask,
682  const GUI_DetailList *geos,
683  bool visible_only,
684  bool contained);
685  void renderOffsetDepthPass(RE_Render *r,
686  bool skip_obj_sel_looks = false,
687  bool skip_guide_looks = false,
688  bool skip_nonsnappable_looks = false,
689  bool skip_current_look = false);
690  void flattenAlphaPass(RE_Render *r,
691  const GUI_DisplayOption *dispopt,
692  int num_layers);
693  // end pick code
694 
695  // Snapping and handle pick code
696  bool createSnapHandleBuffer(RE_Render *r);
697  bool renderHandleBuffer(RE_Render *r);
698  bool renderSnapBuffer(RE_Render *r,
699  unsigned int snapmask,
701  const GUI_DetailList *geos,
702  bool hide_selected,
703  bool enable_occlusion,
704  bool do_current,
705  bool do_xray, bool do_guides,
706  bool extend_floor);
707  // end snapping and handle pick code
708 
709  bool sampleDepth(RE_Render *r, int x, int y, fpreal &z,
710  RE_Texture *depth_texture);
711 
712  void renderXray(RE_Render *r,
713  GUI_DisplayOption *dispopts);
714  void resolveXrayBeautyPass(RE_Render *r) const;
715  void renderOnionSkin(RE_Render *r,
716  GUI_DisplayOption *dispopts);
717 
718  bool renderBeautyPass(RE_Render *r, int x, int y,
719  GUI_DisplayOption *dispopt,
720  bool &needs_lighting);
721  bool renderTransparencyPass(RE_Render *r, int x, int y,
722  GUI_DisplayOption *dispopt);
723  bool renderEnvironmentMaps(RE_Render *r, bool query_only);
724  void renderEnvMap(RE_Render *r,
725  RE_OGLTexture *cubemap,
726  int cubemap_unit) const;
727  void compositePasses(RE_Render *r,
728  const GUI_DisplayOption *dispopt,
729  bool has_trans_pass,
730  bool has_alpha_buffers);
731 
732  void normalQualityRender(
733  RE_Render *r,
734  GUI_DisplayOption *dispopt,
735  GR_AlphaPass alpha_pass,
737  const UT_Array<GUI_DetailLook*> *geos=NULL);
738 
739  bool isUsingHQLighting(RE_Render *r,
740  const GUI_DisplayOption *dispopt);
741 
742  void renderOverlappingUV(RE_Render *r,
743  GUI_DisplayOption *disp);
744  bool setupOverlappingUVBuffer(RE_Render *r, int w, int h);
745  void destroyOverlappingUVBuffer();
746 
747  void renderCoincidentPoints(RE_Render *r,
748  GUI_DisplayOption *disp);
749  bool setupCoincidentBuffer(RE_Render *r, int w, int h);
750  void destroyCoincidentBuffer();
751 
752  void subtractFromSelection(UT_Array<GR_PickRecord> &results,
754  exint start_subtracting_at,
756 #ifdef MBSD_COCOA
757  void dmOSXDepthBufferWorkaround(RE_Render *r,
758  RE_Texture *tex);
759 #endif
760  void updateVisibleBoundariesAndViews(int vis_display_sets);
761 
762  void redrawNeeded(UI_Event *);
763 
764  mutable RE_ShaderHandle *myDepthResolveShader;
765 
766  UT_ValArray<RE_Light *> myMaterialLights;
767 
768  RE_OGLFramebuffer *myBeautyPassBuffer;
769  RE_OGLFramebuffer *myBeautyPassAABuffer;
770  RE_Texture *myBeautyColorTexture;
771  RE_Texture *myBeautyDepthTexture;
772  RE_Texture *myBeautyPassAACTexture;
773  RE_Texture *myBeautyPassAAZTexture;
774  int myBeautyPassSamples;
775  bool myBeautyPassHDR;
776 
777  RE_OGLFramebuffer *myTransparentFBO;
778  RE_Texture *myTransparentColorTex;
779  RE_Texture *myTransparentZTex;
780  bool myTransparentHDR;
781 
782  RE_OGLFramebuffer *mySelectionIDFBO;
783  RE_Texture *mySelectionIDTex;
784  RE_Texture *mySelectionZTex;
785 
786  DM_RenderHighQuality *myHQRender;
787  DM_PostEffects *myPostEffects;
788 
789  RE_Texture *myRandomDitherTexture;
790 
791  PXL_Lookup myLookup;
792  UT_String myLUTFile;
793  UT_String myOCIODisplay;
794 
795  bool myIsBeautyPass;
796  GR_LightingPass myLightingPass;
797  bool myIsAlphaPass;
798  bool myUseUnlitMask;
799  bool myHighQualityMode;
800  bool myNeedsXRayResolve;
801  bool myHasGILight;
802  bool myHasEnvLight;
803  bool myHasCascadingShadowLight;
804  bool myNeedsOverlayRender;
805  uint64 myStandaloneFlag;
806  int myStereoMode;
807  GR_DecorationOverride myDecorationOverride;
808  UT_StringHolder myDisplayedUVAttrib;
809 
810  mutable RE_OGLFramebuffer *myDepthResolveFBO;
811  mutable unsigned int myDepthResolveShaderFailed : 1,
812  myZCompositeShaderFailed : 1;
813 
814  DM_FloorInterface *myFloorInterface;
815  UT_IntArray mySetupLookShowSelection;
816  bool myHasSelectionsShown;
817  bool myDrawFloorTransientFlag;
818  int myDecorLocateMask;
819  int myDecorVisibleMask;
820  int myGammaPass;
821 
822  RE_GPUTimer myBGTimer;
823  RE_GPUTimer myFGTimer;
824  RE_GPUTimer myGeoCleanupTimer;
825  RE_GPUTimer myUnlitTimer;
826 
827  DM_ViewportType myType;
828  int myRenderCount;
829  RE_OGLContext myInitContext;
830 
831  UT_Array<GUI_DetailLookPtr> mySetupLooks;
832  UT_Array<OBJ_Node *> mySetupObjects;
833  UT_Array<GUI_DetailLook *> myUnlitLooks;
834  UT_Array<GUI_DetailLook *> myXRayLooks;
835  UT_Array<GUI_DetailLook *> myOnionSkinLooks;
836  UT_Array<GUI_DetailLook *> myTransparentLooks;
837  UT_Array<OBJ_Node *> myTransparentObjects;
838 
839  bool mySavedAntiAliasOption;
840  UI_XPtr<GUI_SceneLook> mySceneLook;
841  DM_SceneManager &mySceneManager;
842  DM_Viewport *myDisplay;
843  bool mySetupFlag;
844 
845  // Buffers for picking geometry.
846  UT_UniquePtr<RE_PickBuffer> myPickBuffer;
847  UT_TokenString *myPickBufferTestHash;
848 
849  // Extra data for box picking.
850  RE_ShaderHandle myBoxPickObjectShader;
851  RE_Geometry *myBoxPickObjectGeometry;
852  RE_Texture *myBoxPickMaskTexture;
853 
854  // Buffers for snapping to components.
855  UT_UniquePtr<RE_PickBuffer> mySnapHandleBuffer;
856  UT_TokenString *mySnapHandleBufferTestHash;
857 
858  // General position/orientation snapping
859  DM_SnapBuffer *mySnapBuffer;
860  bool mySnapHasValidData;
861 
862  RE_LightList myLightList;
863  UT_ValArray<RE_Light *> myNormalQualityLights;
864 
865  RE_OGLFramebuffer *myUnlitAlphaFBO;
866  RE_Texture *myUnlitAlphaTexture;
867  RE_Texture *myUnlitDepthTexture;
868 
869  static RE_ShaderHandle theBeautyCompShader;
870  static RE_ShaderHandle theBeautyCompAAShader;
871  static RE_ShaderHandle theDepthCompShader;
872  static RE_ShaderHandle theDepthComp8Shader;
873  static RE_ShaderHandle theDepthComp16Shader;
874  static RE_ShaderHandle theAlphaFlatten8Shader;
875  static RE_ShaderHandle theAlphaFlatten16Shader;
876  static RE_ShaderHandle theUnlitAlphaShader;
877  static RE_ShaderHandle theUnlitDepthShader;
878  static RE_ShaderHandle theXRayShader;
879 
880  int myDecorLocateRawPos[2];
881  int myDecorLocatePos[2];
882  RE_ShaderHandle mySampleDepthShader;
883 
884  RE_OGLFramebuffer *myHQTransparentFBO;
885  RE_Texture *myHQTransparentColorTex;
886  RE_Texture *myHQTransparentStencil;
887  bool myHQTransparentHDR;
888 
889  UT_UniquePtr<RE_Geometry> myCubeGeo;
890 
891  RE_OGLFramebuffer *myCoincidentBuffer;
892  RE_Texture *myCoincidentTexture;
893  RE_OGLFramebuffer *myOverlappingUVBuffer;
894 
895  bool myRampUnitPushed;
896 
897  RE_RenderWait *myBeautyPassSync;
898 
899  RE_GPUTimer myPreRenderTimer;
900  RE_GPUTimer myPostRenderTimer;
901  RE_GPUTimer myXRayTimer;
902  RE_GPUTimer myOnionSkinTimer;
903  RE_GPUTimer myCompositeTimer;
904  RE_GPUTimer myBGEnvMapTimer;
905  RE_GPUTimer myDecorTimer;
906  RE_GPUTimer myHandleTimer;
907 
908  bool myUseHQLighting;
909  bool myHasPerLookPickPriority;
910 
911  DM_ViewportHooks *myViewportHooks;
912  UT_IntArray myViewportConfig;
913  UI_Value myRedrawNotify;
914  int myCurrentObjectID;
915 };
916 
917 inline int
919 {
920  return mySetupLooks.entries();
921 }
922 
923 inline DM_GeoDetail
925 {
926  return DM_GeoDetail(mySetupLooks(index));
927 }
928 
929 inline int
931 {
932  return myTransparentLooks.entries();
933 }
934 
935 inline DM_GeoDetail
937 {
938  return DM_GeoDetail(myTransparentLooks(index));
939 }
940 
941 inline int
943 {
944  return myUnlitLooks.entries();
945 }
946 
947 inline DM_GeoDetail
949 {
950  return DM_GeoDetail(myUnlitLooks(index));
951 }
952 
953 inline int
955 {
956  return myXRayLooks.entries();
957 }
958 
959 inline DM_GeoDetail
961 {
962  return DM_GeoDetail(myXRayLooks(index));
963 }
964 
965 #endif
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
void requestDraw()
Request a deferred redraw.
int int32
Definition: SYS_Types.h:39
const UT_ValArray< RE_Light * > & getAllLights() const
bool isGeoSetup() const
GR_DecorationOverride
Definition: GR_Defines.h:203
GLint left
Definition: glcorearb.h:2004
const RE_LightList * getLightList() const
const DM_Viewport * getDisplay() const
GA_API const UT_StringHolder rot
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
int getNumXRayObjects() const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
const DM_FloorInterface * getFloorInterface() const
void close() override
unsigned long long uint64
Definition: SYS_Types.h:117
int getNumTransparentObjects() const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
GR_AlphaPass
Definition: GR_Defines.h:113
GLdouble GLdouble t
Definition: glew.h:1403
DM_ViewportHooks & hooks() const
Interface to viewport hooks (render and mouse)
GLdouble l
Definition: glew.h:9164
DM_GeoDetail getUnlitObject(int index) const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
GLint GLenum GLint x
Definition: glcorearb.h:408
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
#define DM_API
Definition: DM_API.h:10
DM_ViewportType getViewType() const
The projection type of this viewport.
Definition: DM_VPortAgent.h:81
int getNumOpaqueObjects() const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
unsigned char uint8
Definition: SYS_Types.h:36
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:475
void setLightingPass(GR_LightingPass p)
GLuint64EXT * result
Definition: glew.h:14311
ImageBuf OIIO_API sub(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GR_ShadingPass
Definition: GR_Defines.h:122
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GR_RenderMode
Definition: GR_Defines.h:46
GA_API const UT_StringHolder trans
GLint GLuint mask
Definition: glcorearb.h:123
DM_GeoDetail getTransparentObject(int index) const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
GUI_RenderPassFlags
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
const DM_SceneManager & modeler() const
GUI_FogMode
bool needsToDrawFloor() const
GLint GLsizei width
Definition: glcorearb.h:102
GLint GLsizei GLsizei height
Definition: glcorearb.h:102
GLdouble n
Definition: glcorearb.h:2007
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:481
DM_SnapSelection
Definition: DM_Defines.h:208
DM_FloorInterface * getFloorInterface()
Contains transitional objects to provide some backward compatibility for code that references old GEO...
DM_GeoDetail getOpaqueObject(int index) const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
GUI_RotoView
Viewport type for Rotoscope settings.
bool needsOverlayRender() const
RE_LightList * getLightList()
fpreal64 fpreal
Definition: SYS_Types.h:277
DM_GeoDetail getXRayObject(int index) const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
GLuint index
Definition: glcorearb.h:785
DM_GeoSortMode
Definition: DM_Defines.h:150
int getNumUnlitObjects() const
Access displayed objects in the viewport Return a handle to an object displayed in the viewport...
GR_LightingPass
Definition: GR_Defines.h:130
GLuint texture
Definition: glcorearb.h:414
#define DM_VIEWPORT_PERSPECTIVE
GR_LightingPass getLightingPass() const
GLboolean r
Definition: glcorearb.h:1221
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:918
void sort(I begin, I end, const Pred &pred)
Definition: pugixml.cpp:7334
DM_Viewport * getDisplay()
int DM_ViewportType
GLint y
Definition: glcorearb.h:102
GA_API const UT_StringHolder area
Simple interface to building a shader from a .prog file.
GR_PickStyle
Definition: GR_Defines.h:235