HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_EnvControl.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: UT_EnvControl.h ( UT Library, C++)
7  *
8  * COMMENTS: In Houdini applications, there are many environment variables
9  * which control the behaviour of certain features/capabilities.
10  * This class provides a centralized place to efficiently query
11  * these variables. The reason for the centralization is so that
12  * we can easily get a list of these control variables. As well,
13  * this mechanism provides ways of changing the control settings
14  * from environment variables to disk file to registry entry.
15  * Currently only environment variable control is supported.
16  *
17  *
18  * When adding a new environment variable, please document the variable in
19  * $SHD/ref/env.txt
20  */
21 
22 #ifndef __UT_EnvControl__
23 #define __UT_EnvControl__
24 
25 #include "UT_API.h"
26 #include <UT/UT_StringHolder.h>
27 #include <SYS/SYS_StaticAssert.h>
28 #include <SYS/SYS_Types.h>
29 
30 class UT_StringArray;
31 class UT_Variant;
32 
33 namespace UT_Package
34 {
35  class Loader;
36  class Package;
37 }
38 
39 // This define declares a fixed size of array for holding our cached
40 // environment variable values. It should be larger than any of our actual
41 // requirements so that we can add new enum values to the end of these
42 // tables without breaking ABI compatibility (as long as we don't actually
43 // exceed this value and need to increase it).
44 #define MAX_CONTROLS_WITH_BUFFER 512
45 
47 {
48  // UT library: Public interface
66 
67  // UT: Internal controls
79 
80  // Houdini Environment File Control
83 
84  // FS: Public interface
92 
93  // GA: Public interface
95 
96  // IMG3D: Public interface
98 
99  // IMG: Public interface
127  // IMG: Private interface
135 
136  // MV: Public interface
138 
139  // VEX: Public interface
150 
151  // VEX: Private interface
153 
154  // RE: Public interface
164 
165  // CMD
168 
169  // OP
173 
174  // GEO
178 
179  // GU
181 
182  // RAY
194 
197 
220 
221  // COP2
224 
225  // IFD
229 
230  // MAT
232 
233  // UI
254 
255  // OPUI
261 
262  // DM
265 
266  // MATUI
268 
269  // Custom
274 
275  // LM
286 
287  // CHOP
289 
290  // SHOP
293 
294  // VOP
296 
297  // SHLF
300 
301  // Other
307 
308  // Backwards Compatability
317 
329 
331  // Have houdini check process fallback to the old deprecated API
335 
337 
338  // hscript
342 
344 
345  // This is for "internal use" only. It turns on features that are not
346  // ready for prime-time.
348 
349  // Maximum number of files to keep in the backup directory
351 
353 
355 
357 
360 
363 
365 
366  // Controls the number of complete FBX scenes to
367  // keep cached in memory after import. Defaults to 1.
369 
370  // Controls whether to transform the results of evaluating a MotionClip
371  // by the intrinsic matrix of the packed primitive.
373 
378 
380 
383 
384  // OpenGL
388 
389  // OpenCL
396  // Can be used to force disable the use of images for advection by the Gas
397  // Advect CL 2.0 DOP.
399  // Can be used to force use of SwiftShader by the Rasterize Geometry COP.
401 
405 
407 
408  // Maximum megabytes in write buffer.
410 
412 
416 
419 
421 
423 
425 
427 
429 
432 
434 
436 
437  // Used to force regular LM checks on Steam builds
439 
440  // OptiX
442 
444 
445  // Package
448 
449  // Viewer state
451 
453 
455 
457 
458  // TOP
470 
471  // HAPI
473 
474  // LOP
477 
479 
480  // HDA plugin for USD geometry cache size
482 
484 
486 
488 
489  // Send python panel erros to the console
491 
493 
495 
497 
498  // Specify whether or not Houdini GL should use Mtlx materials
500 
501  // New op viewer, defaults to on.
503 
505 
507 
509 
511 
512  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
513  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
516 
517  // Save HDA internal sections alphabetically (where it makes sens)
519 
521 
522  // MV
524 
526 
528 
529  // microfacet conductor fresnel to fix glowing issue with rough metals
531 
533 
534  // texturing issues relating to bad derivatives
536 
538 
540 
542 
545 
546  ENV_MAX_INT_CONTROLS // <- Must be last
547 };
548 
550 {
551  // UT: Public interface
555 
556  // UT: Internal variables
558 
559  // IMG: Public interface
562 
563  // RE
565 
566  // UI
569 
570  // GR
572 
573  // Custom
575 
576  // ROP: Internal variables
578 
579  // OpenCL: Memory pool size, as percentage of GPU memory.
581 
582  // OpenCL: amount of VRAM that IMX layers are allowed to use.
584 
585  // CH
587 
588  // LOP interactive selection redraw time
590 
591  ENV_MAX_FLT_CONTROLS // <- Must be last
592 };
593 
595 {
596  // UT: Public interface
615 
616  // UT: Internal variables
620 
621  // external tools
623 
624  // IMG: Public interface
627 
628  // VEX(VMAT)
637 
638  // HOM
640 
641  // OP
642  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
645 
646  // VOP
648 
649  // GEO
651 
652  // COP
659 
660  // CHOP
662 
663  // TOP
665 
666  // LOP
668 
669  // IFD
675 
676  // UI
687 
688  // FUI
691 
692  // CHUI
694 
695  // OPUI
699 
700  // VEX(VCC)
702 
703  // Custom
711  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
712 
713  // Path variables
745 
749 
751 
754 
756 
762 
764 
769 
776 
779 
781 
783 
784  // These are here so we can have them show up in hconfig and provide
785  // help. They should only be used implicitly.
786  ENV_HSITE, // Between HFS and HOME.
787  ENV_JOB, // We should not use JOB!
788 
790 
793 
795 
796  // OPENGL
803 
804  // OPENCL
811 
812  // Orbolt
814 
815  // Anonymous Usage Statistics
817 
819 
821 
823 
824  // Optix
826 
828 
829  // BGEO plugin for USD default load arguments
831 
832  // LM
850 
851  // Python
853 
854  // Logging
858 
859  // Default asset/material gallery databases
862 
863  // Networking
866 
867  // HQueue
873 
874  // Render delegate to use by default on new Houdini clones
879 
882 
883  ENV_MAX_STR_CONTROLS // <- Must be last
884 };
885 
886 // If these constraints are ever violated in a HEAD branch, it's time to
887 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
888 // a released build, get rid of the "+50" part, and if they are exceeded
889 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
890 // break ABI compatiblity. But hopefully that won't happen...
894 
896 {
897 public:
898  UT_EnvControl();
899  ~UT_EnvControl();
900 
901  UT_EnvControl(const UT_EnvControl &) = delete;
902  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
903 
904  void init();
905 
906  static int getInt(UT_IntControl i)
907  { return getControl().myIValues[i]; }
909  { return getControl().myFValues[i]; }
910  static const char *getString(UT_StrControl i)
911  { return getControl().mySValues[i]; }
912 
913  // Look up the appropriate variable name for the token
914  static const char *getIntVar(UT_IntControl i);
915  static const char *getFloatVar(UT_FltControl i);
916  static const char *getStringVar(UT_StrControl i);
917 
918  static void setStringVar(UT_StrControl i, const char *value);
919 
920  // Look up the appropriate old style variable name for the token. This can
921  // be used to check for old environment variables.
922  static const char *getOldIntVar(UT_IntControl i);
923  static const char *getOldFloatVar(UT_FltControl i);
924  static const char *getOldStringVar(UT_StrControl i);
925 
926  /// Indicate that the given variable changed and update our cached values.
927  /// If varname is NULL, then all variables are updated.
928  static void varChanged(const char *varname)
929  { varChanged(varname, nullptr); }
930 
931  /// Update the cached varname value with the given value so that we can
932  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
933  /// @code
934  /// HoudiniSetenv(name, value);
935  /// UT_EnvControl::varChanged(name);
936  /// @endcode
937  /// @return true if name was found and value is non-null, in which case the
938  /// HoudiniSetenv() was called, else false is returned.
939  static bool varChanged(const char *varname, const char *value);
940 
941  static void changeExistLookupDefault(UT_IntControl i, int new_def);
942 
943  /// Queries the cached variable value. Unrecognized variables are
944  /// returned as UT_Variant::Type::Unknown. String values are returned
945  /// as UT_Variant::Type::Pointer to allow distinguishing between null
946  /// pointers and empty strings. If you intend to hold onto the string
947  /// value beyond immediately using it, you must make your own copy!
948  static UT_Variant getVarValue(const char *varname);
949 
950  /// Set all additional .env files to be parsed for env variable values.
951  /// It is best to call getAdditionalEnvironmentFiles() first and then
952  /// append to the list because this function will overwrite all the
953  /// additional paths that were previously set.
954  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
955  /// overwrites, knowing that these files get applied AFTER the default
956  /// houdini.env file in the user's home directory.
957  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
958  /// If additional files are set, they will be used, regardless of the
959  /// value of HOUDINI_NO_ENV_FILE.
960  static void setAdditionalEnvironmentFiles(
961  const UT_StringArray &files);
962 
963  /// Return the current list of additional environment files.
964  static const UT_StringArray&
965  getAdditionalEnvironmentFiles();
966 
967  // Print messages collected during init phase to console
968  static void logMessages()
969  {
970  getControl().logMessagesToConsole();
971  }
972 
973  // Package loader management
974  // Load the pakages located in the folders specified by pkg_paths.
975  // Use this method for loading package dynamically
976  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
977  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
978 
979  // Returns the main package loader, this loader contains all
980  // packages loaded at runtime.
981  static UT_Package::Loader& packageLoader();
982 
983 private:
984  void doInit(bool init_defaults);
985  void setDefaults();
986  bool loadEnvironmentFile(const char *path,
987  bool allow_overrides);
988  void loadDefaultEnvironmentFile();
989  void loadEnvironmentFiles();
990  void loadEnvironment(bool init_defaults);
991 
992  void updateExistLookup(int i, const char *value = nullptr);
993  void updateIntLookup(int i, const char *value = nullptr);
994  void updateFltLookup(int i, const char *value = nullptr);
995  void updateStrLookup(int i, bool fix_path,
996  const char *value = nullptr);
997 
998  void updateVarTables(UT_Package::Loader const& pkg_loader);
999 
1000  void loadPackageConfig();
1001  void logMessagesToConsole() const;
1002 
1003  int myIValues[MAX_CONTROLS_WITH_BUFFER];
1004  float myFValues[MAX_CONTROLS_WITH_BUFFER];
1005  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
1006 
1007  static UT_EnvControl &getControl()
1008  {
1009  if (!theControl)
1010  {
1011  theControl = new UT_EnvControl();
1012  theControl->init();
1013 
1014  }
1015  return *theControl;
1016  }
1017  static UT_EnvControl *theControl;
1018 
1019  UT_StringHolder myLogMessages;
1020 };
1021 
1022 #endif
static void varChanged(const char *varname)
static const char * getString(UT_StrControl i)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
#define UT_API
Definition: UT_API.h:14
static void logMessages()
UT_StrControl
static int getInt(UT_IntControl i)
static fpreal getFloat(UT_FltControl i)
fpreal64 fpreal
Definition: SYS_Types.h:277
LeafData & operator=(const LeafData &)=delete
SYS_STATIC_ASSERT(ENV_MAX_INT_CONTROLS+50< MAX_CONTROLS_WITH_BUFFER)
Definition: core.h:1131
UT_FltControl
#define MAX_CONTROLS_WITH_BUFFER
Definition: UT_EnvControl.h:44
UT_IntControl
Definition: UT_EnvControl.h:46