ParticleEditorUi.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Ui.h>
  7. #include <AnKi/Resource/ParticleEmitterResource2.h>
  8. namespace anki {
  9. class ParticleEditorUi
  10. {
  11. public:
  12. void open(const ParticleEmitterResource2& resource);
  13. void drawWindow(UiCanvas& canvas, Vec2 initialPos, Vec2 initialSize, ImGuiWindowFlags windowFlags = 0);
  14. private:
  15. class Prop
  16. {
  17. public:
  18. union
  19. {
  20. #define ANKI_SVDT_MACRO(type, baseType, rowCount, columnCount, isIntagralType) type ANKI_CONCATENATE(m_, type);
  21. #include <AnKi/Gr/ShaderVariableDataType.def.h>
  22. };
  23. String m_name;
  24. ShaderVariableDataType m_type = ShaderVariableDataType::kNone;
  25. Prop()
  26. {
  27. m_Mat4 = Mat4(0.0f);
  28. }
  29. Prop(const Prop& b)
  30. {
  31. *this = b;
  32. }
  33. Prop& operator=(const Prop& b)
  34. {
  35. m_name = b.m_name;
  36. m_type = b.m_type;
  37. m_Mat4 = b.m_Mat4;
  38. return *this;
  39. }
  40. };
  41. class ParticleProgram
  42. {
  43. public:
  44. String m_filename;
  45. String m_name;
  46. DynamicArray<Prop> m_props;
  47. };
  48. Bool m_open = false;
  49. DynamicArray<ParticleProgram> m_programs;
  50. String m_filename;
  51. // Cache begin. The UI will manipulate this cache because the resource is immutable
  52. String m_currentlySelectedProgram;
  53. ParticleEmitterResourceCommonProperties m_commonProps = {};
  54. DynamicArray<Prop> m_otherProps;
  55. // Cache end
  56. // Look at the filesystem and get the programs that are for particles
  57. void gatherParticlePrograms();
  58. void rebuildCache(const ParticleEmitterResource2& resource);
  59. void rebuildCache(CString particleProgramName);
  60. Error saveCache();
  61. };
  62. } // end namespace anki