register_server_types.cpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*************************************************************************/
  2. /* register_server_types.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "register_server_types.h"
  31. #include "core/engine.h"
  32. #include "core/project_settings.h"
  33. #include "arvr/arvr_interface.h"
  34. #include "arvr/arvr_positional_tracker.h"
  35. #include "arvr_server.h"
  36. #include "audio/audio_effect.h"
  37. #include "audio/audio_stream.h"
  38. #include "audio/effects/audio_effect_amplify.h"
  39. #include "audio/effects/audio_effect_chorus.h"
  40. #include "audio/effects/audio_effect_compressor.h"
  41. #include "audio/effects/audio_effect_delay.h"
  42. #include "audio/effects/audio_effect_distortion.h"
  43. #include "audio/effects/audio_effect_eq.h"
  44. #include "audio/effects/audio_effect_filter.h"
  45. #include "audio/effects/audio_effect_limiter.h"
  46. #include "audio/effects/audio_effect_panner.h"
  47. #include "audio/effects/audio_effect_phaser.h"
  48. #include "audio/effects/audio_effect_pitch_shift.h"
  49. #include "audio/effects/audio_effect_record.h"
  50. #include "audio/effects/audio_effect_reverb.h"
  51. #include "audio/effects/audio_effect_spectrum_analyzer.h"
  52. #include "audio/effects/audio_effect_stereo_enhance.h"
  53. #include "audio/effects/audio_stream_generator.h"
  54. #include "audio_server.h"
  55. #include "camera/camera_feed.h"
  56. #include "camera_server.h"
  57. #include "navigation_2d_server.h"
  58. #include "navigation_server.h"
  59. #include "physics/physics_server_sw.h"
  60. #include "physics_2d/physics_2d_server_sw.h"
  61. #include "physics_2d/physics_2d_server_wrap_mt.h"
  62. #include "physics_2d_server.h"
  63. #include "physics_server.h"
  64. #include "visual/shader_types.h"
  65. #include "visual_server.h"
  66. ShaderTypes *shader_types = NULL;
  67. PhysicsServer *_createGodotPhysicsCallback() {
  68. return memnew(PhysicsServerSW);
  69. }
  70. Physics2DServer *_createGodotPhysics2DCallback() {
  71. return Physics2DServerWrapMT::init_server<Physics2DServerSW>();
  72. }
  73. static bool has_server_feature_callback(const String &p_feature) {
  74. if (VisualServer::get_singleton()) {
  75. if (VisualServer::get_singleton()->has_os_feature(p_feature)) {
  76. return true;
  77. }
  78. }
  79. return false;
  80. }
  81. void preregister_server_types() {
  82. shader_types = memnew(ShaderTypes);
  83. }
  84. void register_server_types() {
  85. OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback);
  86. ClassDB::register_virtual_class<VisualServer>();
  87. ClassDB::register_class<AudioServer>();
  88. ClassDB::register_virtual_class<PhysicsServer>();
  89. ClassDB::register_virtual_class<Physics2DServer>();
  90. ClassDB::register_class<ARVRServer>();
  91. ClassDB::register_class<CameraServer>();
  92. ClassDB::register_virtual_class<ARVRInterface>();
  93. ClassDB::register_class<ARVRPositionalTracker>();
  94. ClassDB::register_virtual_class<AudioStream>();
  95. ClassDB::register_virtual_class<AudioStreamPlayback>();
  96. ClassDB::register_virtual_class<AudioStreamPlaybackResampled>();
  97. ClassDB::register_class<AudioStreamMicrophone>();
  98. ClassDB::register_class<AudioStreamRandomPitch>();
  99. ClassDB::register_virtual_class<AudioEffect>();
  100. ClassDB::register_virtual_class<AudioEffectInstance>();
  101. ClassDB::register_class<AudioEffectEQ>();
  102. ClassDB::register_class<AudioEffectFilter>();
  103. ClassDB::register_class<AudioBusLayout>();
  104. ClassDB::register_class<AudioStreamGenerator>();
  105. ClassDB::register_virtual_class<AudioStreamGeneratorPlayback>();
  106. {
  107. //audio effects
  108. ClassDB::register_class<AudioEffectAmplify>();
  109. ClassDB::register_class<AudioEffectReverb>();
  110. ClassDB::register_class<AudioEffectLowPassFilter>();
  111. ClassDB::register_class<AudioEffectHighPassFilter>();
  112. ClassDB::register_class<AudioEffectBandPassFilter>();
  113. ClassDB::register_class<AudioEffectNotchFilter>();
  114. ClassDB::register_class<AudioEffectBandLimitFilter>();
  115. ClassDB::register_class<AudioEffectLowShelfFilter>();
  116. ClassDB::register_class<AudioEffectHighShelfFilter>();
  117. ClassDB::register_class<AudioEffectEQ6>();
  118. ClassDB::register_class<AudioEffectEQ10>();
  119. ClassDB::register_class<AudioEffectEQ21>();
  120. ClassDB::register_class<AudioEffectDistortion>();
  121. ClassDB::register_class<AudioEffectStereoEnhance>();
  122. ClassDB::register_class<AudioEffectPanner>();
  123. ClassDB::register_class<AudioEffectChorus>();
  124. ClassDB::register_class<AudioEffectDelay>();
  125. ClassDB::register_class<AudioEffectCompressor>();
  126. ClassDB::register_class<AudioEffectLimiter>();
  127. ClassDB::register_class<AudioEffectPitchShift>();
  128. ClassDB::register_class<AudioEffectPhaser>();
  129. ClassDB::register_class<AudioEffectRecord>();
  130. ClassDB::register_class<AudioEffectSpectrumAnalyzer>();
  131. ClassDB::register_virtual_class<AudioEffectSpectrumAnalyzerInstance>();
  132. }
  133. ClassDB::register_class<CameraFeed>();
  134. ClassDB::register_virtual_class<Physics2DDirectBodyState>();
  135. ClassDB::register_virtual_class<Physics2DDirectSpaceState>();
  136. ClassDB::register_virtual_class<Physics2DShapeQueryResult>();
  137. ClassDB::register_class<Physics2DTestMotionResult>();
  138. ClassDB::register_class<Physics2DShapeQueryParameters>();
  139. ClassDB::register_class<PhysicsShapeQueryParameters>();
  140. ClassDB::register_virtual_class<PhysicsDirectBodyState>();
  141. ClassDB::register_virtual_class<PhysicsDirectSpaceState>();
  142. ClassDB::register_virtual_class<PhysicsShapeQueryResult>();
  143. // Physics 2D
  144. GLOBAL_DEF(Physics2DServerManager::setting_property_name, "DEFAULT");
  145. ProjectSettings::get_singleton()->set_custom_property_info(Physics2DServerManager::setting_property_name, PropertyInfo(Variant::STRING, Physics2DServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
  146. Physics2DServerManager::register_server("GodotPhysics", &_createGodotPhysics2DCallback);
  147. Physics2DServerManager::set_default_server("GodotPhysics");
  148. // Physics 3D
  149. GLOBAL_DEF(PhysicsServerManager::setting_property_name, "DEFAULT");
  150. ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServerManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT"));
  151. PhysicsServerManager::register_server("GodotPhysics", &_createGodotPhysicsCallback);
  152. PhysicsServerManager::set_default_server("GodotPhysics");
  153. }
  154. void unregister_server_types() {
  155. memdelete(shader_types);
  156. }
  157. void register_server_singletons() {
  158. Engine::get_singleton()->add_singleton(Engine::Singleton("VisualServer", VisualServer::get_singleton()));
  159. Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton()));
  160. Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer", PhysicsServer::get_singleton()));
  161. Engine::get_singleton()->add_singleton(Engine::Singleton("Physics2DServer", Physics2DServer::get_singleton()));
  162. Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer", NavigationServer::get_singleton_mut()));
  163. Engine::get_singleton()->add_singleton(Engine::Singleton("Navigation2DServer", Navigation2DServer::get_singleton_mut()));
  164. Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton()));
  165. Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton()));
  166. }