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 
32 namespace UT_Package
33 {
34  class Loader;
35  class Package;
36 }
37 
38 // This define declares a fixed size of array for holding our cached
39 // environment variable values. It should be larger than any of our actual
40 // requirements so that we can add new enum values to the end of these
41 // tables without breaking ABI compatibility (as long as we don't actually
42 // exceed this value and need to increase it).
43 #define MAX_CONTROLS_WITH_BUFFER 512
44 
46 {
47  // UT library: Public interface
65 
66  // UT: Internal controls
78 
79  // Houdini Environment File Control
82 
83  // FS: Public interface
91 
92  // GA: Public interface
94 
95  // IMG3D: Public interface
97 
98  // IMG: Public interface
126  // IMG: Private interface
134 
135  // MV: Public interface
137 
138  // VEX: Public interface
149 
150  // VEX: Private interface
152 
153  // RE: Public interface
163 
164  // CMD
167 
168  // OP
172 
173  // GEO
177 
178  // GU
180 
181  // RAY
193 
196 
218 
219  // COP2
222 
223  // IFD
227 
228  // MAT
230 
231  // UI
251 
252  // OPUI
258 
259  // DM
262 
263  // MATUI
265 
266  // Custom
271 
272  // LM
283 
284  // CHOP
286 
287  // SHOP
290 
291  // VOP
293 
294  // SHLF
297 
298  // Other
304 
305  // Backwards Compatability
314 
326 
328  // Have houdini check process fallback to the old deprecated API
332 
334 
335  // hscript
339 
341 
342  // This is for "internal use" only. It turns on features that are not
343  // ready for prime-time.
345 
346  // Maximum number of files to keep in the backup directory
348 
350 
352 
354 
357 
360 
362 
363  // Controls the number of complete FBX scenes to
364  // keep cached in memory after import. Defaults to 1.
366 
367  // Controls whether to transform the results of evaluating a MotionClip
368  // by the intrinsic matrix of the packed primitive.
370 
375 
377 
380 
381  // OpenGL
385 
386  // OpenCL
391  // Can be used to force disable the use of images for advection by the Gas
392  // Advect CL 2.0 DOP.
394 
398 
400 
401  // Maximum megabytes in write buffer.
403 
405 
409 
412 
414 
416 
418 
420 
422 
425 
427 
429 
430  // Used to force regular LM checks on Steam builds
432 
433  // OptiX
435 
437 
438  // Package
441 
442  // Viewer state
444 
446 
448 
450 
451  // TOP
463 
464  // HAPI
466 
467  // LOP
470 
472 
473  // HDA plugin for USD geometry cache size
475 
477 
479 
481 
482  // Send python panel erros to the console
484 
486 
488 
490 
491  // Specify whether or not Houdini GL should use Mtlx materials
493 
494  // New op viewer, defaults to on.
496 
498 
500 
502 
503  ENV_KARMA_DICING_LEGACY, // Karma legacy dicing behaviour
504  ENV_KARMA_VARYING_ARRAY_PRIMVARS, // Varying length array primvars
505 
506  // Save HDA internal sections alphabetically (where it makes sens)
508 
510 
511  // MV
513 
515 
517 
518  // microfacet conductor fresnel to fix glowing issue with rough metals
520 
521  // texturing issues relating to bad derivatives
523 
525 
527 
529 };
530 
532 {
533  // UT: Public interface
537 
538  // UT: Internal variables
540 
541  // IMG: Public interface
544 
545  // RE
547 
548  // UI
551 
552  // GR
554 
555  // Custom
557 
558  // ROP: Internal variables
560 
561  // OpenCL: Memory pool size, as percentage of GPU memory.
563 
564  // CH
566 
568 };
569 
571 {
572  // UT: Public interface
591 
592  // UT: Internal variables
596 
597  // external tools
599 
600  // IMG: Public interface
603 
604  // VEX(VMAT)
613 
614  // HOM
616 
617  // OP
618  ENV_HOUDINI_HIP_DEFAULT_NAME, // "untitled.hip"
621 
622  // VOP
624 
625  // GEO
627 
628  // COP
635 
636  // CHOP
638 
639  // TOP
641 
642  // IFD
648 
649  // UI
660 
661  // FUI
664 
665  // CHUI
667 
668  // OPUI
672 
673  // VEX(VCC)
675 
676  // Custom
684  ENV_HOUDINI_VIEW_METACAM, //OTLs that lock to view in a special way
685 
686  // Path variables
718 
722 
724 
726 
728 
734 
736 
741 
748 
750 
752 
753  // These are here so we can have them show up in hconfig and provide
754  // help. They should only be used implicitly.
755  ENV_HSITE, // Between HFS and HOME.
756  ENV_JOB, // We should not use JOB!
757 
759 
762 
764 
765  // OPENGL
772 
773  // OPENCL
778 
779  // Orbolt
781 
782  // Anonymous Usage Statistics
784 
786 
788 
790 
791  // Optix
793 
795 
796  // BGEO plugin for USD default load arguments
798 
799  // LM
815 
816  // Python
818 
819  // Logging
821 
822  // Default asset/material gallery databases
825 
826  // Networking
829 
830  // HQueue
836 
838 };
839 
840 // If these constraints are ever violated in a HEAD branch, it's time to
841 // increase MAX_CONTROLS_WITH_BUFFER. If these constraints are violated in
842 // a released build, get rid of the "+50" part, and if they are exceeded
843 // again then we must increate MAX_CONTROLS_WITH_BUFFER in a daily build and
844 // break ABI compatiblity. But hopefully that won't happen...
848 
850 {
851 public:
852  UT_EnvControl();
853  ~UT_EnvControl();
854 
855  UT_EnvControl(const UT_EnvControl &) = delete;
856  UT_EnvControl &operator=(const UT_EnvControl &) = delete;
857 
858  void init();
859 
860  static int getInt(UT_IntControl i)
861  { return getControl().myIValues[i]; }
863  { return getControl().myFValues[i]; }
864  static const char *getString(UT_StrControl i)
865  { return getControl().mySValues[i]; }
866 
867  // Look up the appropriate variable name for the token
868  static const char *getIntVar(UT_IntControl i);
869  static const char *getFloatVar(UT_FltControl i);
870  static const char *getStringVar(UT_StrControl i);
871 
872  static void setStringVar(UT_StrControl i, const char *value);
873 
874  // Look up the appropriate old style variable name for the token. This can
875  // be used to check for old environment variables.
876  static const char *getOldIntVar(UT_IntControl i);
877  static const char *getOldFloatVar(UT_FltControl i);
878  static const char *getOldStringVar(UT_StrControl i);
879 
880  /// Indicate that the given variable changed and update our cached values.
881  /// If varname is NULL, then all variables are updated.
882  static void varChanged(const char *varname)
883  { varChanged(varname, nullptr); }
884 
885  /// Update the cached varname value with the given value so that we can
886  /// avoid an extraneous HoudiniGetenv() for the equivalent code snippet:
887  /// @code
888  /// HoudiniSetenv(name, value);
889  /// UT_EnvControl::varChanged(name);
890  /// @endcode
891  /// @return true if name was found and value is non-null, in which case the
892  /// HoudiniSetenv() was called, else false is returned.
893  static bool varChanged(const char *varname, const char *value);
894 
895  static void changeExistLookupDefault(UT_IntControl i, int new_def);
896 
897  /// Set all additional .env files to be parsed for env variable values.
898  /// It is best to call getAdditionalEnvironmentFiles() first and then
899  /// append to the list because this function will overwrite all the
900  /// additional paths that were previously set.
901  /// You can still use the HOUDINI_NO_ENV_FILE_OVERRIDES to disallow
902  /// overwrites, knowing that these files get applied AFTER the default
903  /// houdini.env file in the user's home directory.
904  /// That said, HOUDINI_NO_ENV_FILE will have no effect on this function.
905  /// If additional files are set, they will be used, regardless of the
906  /// value of HOUDINI_NO_ENV_FILE.
907  static void setAdditionalEnvironmentFiles(
908  const UT_StringArray &files);
909 
910  /// Return the current list of additional environment files.
911  static const UT_StringArray&
912  getAdditionalEnvironmentFiles();
913 
914  // Print messages collected during init phase to console
915  static void logMessages()
916  {
917  getControl().logMessagesToConsole();
918  }
919 
920  // Package loader management
921  // Load the pakages located in the folders specified by pkg_paths.
922  // Use this method for loading package dynamically
923  static void loadPackages(UT_StringArray const &pkg_paths, UT_Package::Loader& pkg_loader);
924  static UT_Package::Package & loadPackage(char const * pkg_filepath, UT_Package::Loader& pkg_loader);
925 
926  // Returns the main package loader, this loader contains all
927  // packages loaded at runtime.
928  static UT_Package::Loader& packageLoader();
929 
930 private:
931  void doInit(bool init_defaults);
932  void setDefaults();
933  bool loadEnvironmentFile(const char *path,
934  bool allow_overrides);
935  void loadDefaultEnvironmentFile();
936  void loadEnvironmentFiles();
937  void loadEnvironment(bool init_defaults);
938 
939  void updateExistLookup(int i, const char *value = nullptr);
940  void updateIntLookup(int i, const char *value = nullptr);
941  void updateFltLookup(int i, const char *value = nullptr);
942  void updateStrLookup(int i, bool fix_path,
943  const char *value = nullptr);
944 
945  void updateVarTables(UT_Package::Loader const& pkg_loader);
946 
947  void loadPackageConfig();
948  void logMessagesToConsole() const;
949 
950  int myIValues[MAX_CONTROLS_WITH_BUFFER];
951  float myFValues[MAX_CONTROLS_WITH_BUFFER];
952  char *mySValues[MAX_CONTROLS_WITH_BUFFER];
953 
954  static UT_EnvControl &getControl()
955  {
956  if (!theControl)
957  {
958  theControl = new UT_EnvControl();
959  theControl->init();
960 
961  }
962  return *theControl;
963  }
964  static UT_EnvControl *theControl;
965 
966  UT_StringHolder myLogMessages;
967 };
968 
969 #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
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:43
UT_IntControl
Definition: UT_EnvControl.h:45