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