path_3d.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /**************************************************************************/
  2. /* path_3d.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 "path_3d.h"
  31. #include "scene/resources/mesh.h"
  32. Path3D::Path3D() {
  33. SceneTree *st = SceneTree::get_singleton();
  34. if (st && st->is_debugging_paths_hint()) {
  35. debug_instance = RS::get_singleton()->instance_create();
  36. set_notify_transform(true);
  37. _update_debug_mesh();
  38. }
  39. }
  40. Path3D::~Path3D() {
  41. if (debug_instance.is_valid()) {
  42. ERR_FAIL_NULL(RenderingServer::get_singleton());
  43. RS::get_singleton()->free_rid(debug_instance);
  44. }
  45. if (debug_mesh.is_valid()) {
  46. ERR_FAIL_NULL(RenderingServer::get_singleton());
  47. RS::get_singleton()->free_rid(debug_mesh->get_rid());
  48. }
  49. }
  50. void Path3D::set_update_callback(Callable p_callback) {
  51. update_callback = p_callback;
  52. }
  53. void Path3D::_notification(int p_what) {
  54. switch (p_what) {
  55. case NOTIFICATION_ENTER_TREE: {
  56. SceneTree *st = SceneTree::get_singleton();
  57. if (st && st->is_debugging_paths_hint()) {
  58. _update_debug_mesh();
  59. }
  60. } break;
  61. case NOTIFICATION_EXIT_TREE: {
  62. SceneTree *st = SceneTree::get_singleton();
  63. if (st && st->is_debugging_paths_hint()) {
  64. RS::get_singleton()->instance_set_visible(debug_instance, false);
  65. }
  66. } break;
  67. case NOTIFICATION_TRANSFORM_CHANGED: {
  68. if (is_inside_tree()) {
  69. if (debug_instance.is_valid()) {
  70. RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
  71. }
  72. update_callback.call();
  73. }
  74. } break;
  75. }
  76. }
  77. void Path3D::_update_debug_mesh() {
  78. SceneTree *st = SceneTree::get_singleton();
  79. if (!(st && st->is_debugging_paths_hint())) {
  80. return;
  81. }
  82. if (debug_mesh.is_null()) {
  83. debug_mesh.instantiate();
  84. }
  85. if (curve.is_null()) {
  86. RS::get_singleton()->instance_set_visible(debug_instance, false);
  87. return;
  88. }
  89. if (curve->get_point_count() < 2) {
  90. RS::get_singleton()->instance_set_visible(debug_instance, false);
  91. return;
  92. }
  93. real_t interval = 0.1;
  94. const real_t length = curve->get_baked_length();
  95. if (length <= CMP_EPSILON) {
  96. RS::get_singleton()->instance_set_visible(debug_instance, false);
  97. return;
  98. }
  99. const int sample_count = int(length / interval) + 2;
  100. interval = length / (sample_count - 1);
  101. Vector<Vector3> ribbon;
  102. ribbon.resize(sample_count);
  103. Vector3 *ribbon_ptr = ribbon.ptrw();
  104. Vector<Vector3> bones;
  105. bones.resize(sample_count * 4);
  106. Vector3 *bones_ptr = bones.ptrw();
  107. for (int i = 0; i < sample_count; i++) {
  108. const Transform3D r = curve->sample_baked_with_rotation(i * interval, true, true);
  109. const Vector3 p1 = r.origin;
  110. const Vector3 side = r.basis.get_column(0);
  111. const Vector3 up = r.basis.get_column(1);
  112. const Vector3 forward = r.basis.get_column(2);
  113. // Path3D as a ribbon.
  114. ribbon_ptr[i] = p1;
  115. if (i % 4 == 0) {
  116. // Draw fish bone every 4 points to reduce visual noise and performance impact
  117. // (compared to drawing it for every point).
  118. const Vector3 p_left = p1 + (side + forward - up * 0.3) * 0.06;
  119. const Vector3 p_right = p1 + (-side + forward - up * 0.3) * 0.06;
  120. const int bone_idx = i * 4;
  121. bones_ptr[bone_idx] = p1;
  122. bones_ptr[bone_idx + 1] = p_left;
  123. bones_ptr[bone_idx + 2] = p1;
  124. bones_ptr[bone_idx + 3] = p_right;
  125. }
  126. }
  127. Array ribbon_array;
  128. ribbon_array.resize(Mesh::ARRAY_MAX);
  129. ribbon_array[Mesh::ARRAY_VERTEX] = ribbon;
  130. Array bone_array;
  131. bone_array.resize(Mesh::ARRAY_MAX);
  132. bone_array[Mesh::ARRAY_VERTEX] = bones;
  133. _update_debug_path_material();
  134. debug_mesh->clear_surfaces();
  135. debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINE_STRIP, ribbon_array);
  136. debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, bone_array);
  137. debug_mesh->surface_set_material(0, debug_material);
  138. debug_mesh->surface_set_material(1, debug_material);
  139. RS::get_singleton()->instance_set_base(debug_instance, debug_mesh->get_rid());
  140. if (is_inside_tree()) {
  141. RS::get_singleton()->instance_set_scenario(debug_instance, get_world_3d()->get_scenario());
  142. RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
  143. RS::get_singleton()->instance_set_visible(debug_instance, is_visible_in_tree());
  144. }
  145. }
  146. void Path3D::set_debug_custom_color(const Color &p_color) {
  147. debug_custom_color = p_color;
  148. _update_debug_path_material();
  149. }
  150. Ref<StandardMaterial3D> Path3D::get_debug_material() {
  151. return debug_material;
  152. }
  153. const Color &Path3D::get_debug_custom_color() const {
  154. return debug_custom_color;
  155. }
  156. void Path3D::_update_debug_path_material() {
  157. SceneTree *st = SceneTree::get_singleton();
  158. if (!debug_material.is_valid()) {
  159. Ref<StandardMaterial3D> material = memnew(StandardMaterial3D);
  160. debug_material = material;
  161. material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
  162. material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
  163. material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
  164. material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
  165. material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
  166. }
  167. Color color = debug_custom_color;
  168. if (color == Color(0.0, 0.0, 0.0)) {
  169. // Use the default debug path color defined in the Project Settings.
  170. color = st->get_debug_paths_color();
  171. }
  172. get_debug_material()->set_albedo(color);
  173. emit_signal(SNAME("debug_color_changed"));
  174. }
  175. void Path3D::_curve_changed() {
  176. if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
  177. update_gizmos();
  178. }
  179. if (is_inside_tree()) {
  180. emit_signal(SNAME("curve_changed"));
  181. }
  182. // Update the configuration warnings of all children of type PathFollow
  183. // previously used for PathFollowOriented (now enforced orientation is done in PathFollow). Also trigger transform update on PathFollow3Ds in deferred mode.
  184. if (is_inside_tree()) {
  185. for (int i = 0; i < get_child_count(); i++) {
  186. PathFollow3D *child = Object::cast_to<PathFollow3D>(get_child(i));
  187. if (child) {
  188. child->update_configuration_warnings();
  189. child->update_transform();
  190. }
  191. }
  192. }
  193. SceneTree *st = SceneTree::get_singleton();
  194. if (st && st->is_debugging_paths_hint()) {
  195. _update_debug_mesh();
  196. }
  197. }
  198. void Path3D::set_curve(const Ref<Curve3D> &p_curve) {
  199. if (curve.is_valid()) {
  200. curve->disconnect_changed(callable_mp(this, &Path3D::_curve_changed));
  201. }
  202. curve = p_curve;
  203. if (curve.is_valid()) {
  204. curve->connect_changed(callable_mp(this, &Path3D::_curve_changed));
  205. }
  206. _curve_changed();
  207. }
  208. Ref<Curve3D> Path3D::get_curve() const {
  209. return curve;
  210. }
  211. void Path3D::_bind_methods() {
  212. ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve);
  213. ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve);
  214. ClassDB::bind_method(D_METHOD("set_debug_custom_color", "debug_custom_color"), &Path3D::set_debug_custom_color);
  215. ClassDB::bind_method(D_METHOD("get_debug_custom_color"), &Path3D::get_debug_custom_color);
  216. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
  217. ADD_GROUP("Debug Shape", "debug_");
  218. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_custom_color"), "set_debug_custom_color", "get_debug_custom_color");
  219. ADD_SIGNAL(MethodInfo("curve_changed"));
  220. ADD_SIGNAL(MethodInfo("debug_color_changed"));
  221. }
  222. void PathFollow3D::update_transform() {
  223. if (!path) {
  224. return;
  225. }
  226. Ref<Curve3D> c = path->get_curve();
  227. if (c.is_null()) {
  228. return;
  229. }
  230. real_t bl = c->get_baked_length();
  231. if (bl == 0.0) {
  232. return;
  233. }
  234. Transform3D t;
  235. if (rotation_mode == ROTATION_NONE) {
  236. Vector3 pos = c->sample_baked(progress, cubic);
  237. t.origin = pos;
  238. } else {
  239. t = c->sample_baked_with_rotation(progress, cubic, false);
  240. Vector3 tangent = -t.basis.get_column(2); // Retain tangent for applying tilt.
  241. t = PathFollow3D::correct_posture(t, rotation_mode);
  242. // Switch Z+ and Z- if necessary.
  243. if (use_model_front) {
  244. t.basis *= Basis::from_scale(Vector3(-1.0, 1.0, -1.0));
  245. }
  246. // Apply tilt *after* correct_posture().
  247. if (tilt_enabled) {
  248. const real_t tilt = c->sample_baked_tilt(progress);
  249. const Basis twist(tangent, tilt);
  250. t.basis = twist * t.basis;
  251. }
  252. }
  253. // Apply offset and scale.
  254. Vector3 scale = get_transform().basis.get_scale();
  255. t.translate_local(Vector3(h_offset, v_offset, 0));
  256. t.basis.scale_local(scale);
  257. set_transform(t);
  258. }
  259. void PathFollow3D::_notification(int p_what) {
  260. switch (p_what) {
  261. case NOTIFICATION_ENTER_TREE: {
  262. Node *parent = get_parent();
  263. if (parent) {
  264. path = Object::cast_to<Path3D>(parent);
  265. update_transform();
  266. }
  267. } break;
  268. case NOTIFICATION_EXIT_TREE: {
  269. path = nullptr;
  270. } break;
  271. }
  272. }
  273. void PathFollow3D::set_cubic_interpolation_enabled(bool p_enabled) {
  274. cubic = p_enabled;
  275. }
  276. bool PathFollow3D::is_cubic_interpolation_enabled() const {
  277. return cubic;
  278. }
  279. void PathFollow3D::_validate_property(PropertyInfo &p_property) const {
  280. if (!Engine::get_singleton()->is_editor_hint()) {
  281. return;
  282. }
  283. if (p_property.name == "offset") {
  284. real_t max = 10000;
  285. if (path && path->get_curve().is_valid()) {
  286. max = path->get_curve()->get_baked_length();
  287. }
  288. p_property.hint_string = "0," + rtos(max) + ",0.01,or_less,or_greater";
  289. }
  290. }
  291. PackedStringArray PathFollow3D::get_configuration_warnings() const {
  292. PackedStringArray warnings = Node3D::get_configuration_warnings();
  293. if (is_visible_in_tree() && is_inside_tree()) {
  294. if (!Object::cast_to<Path3D>(get_parent())) {
  295. warnings.push_back(RTR("PathFollow3D only works when set as a child of a Path3D node."));
  296. } else {
  297. Path3D *p = Object::cast_to<Path3D>(get_parent());
  298. if (p->get_curve().is_valid() && !p->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) {
  299. warnings.push_back(RTR("PathFollow3D's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path3D's Curve resource."));
  300. }
  301. }
  302. }
  303. return warnings;
  304. }
  305. Transform3D PathFollow3D::correct_posture(Transform3D p_transform, PathFollow3D::RotationMode p_rotation_mode) {
  306. Transform3D t = p_transform;
  307. // Modify frame according to rotation mode.
  308. if (p_rotation_mode == PathFollow3D::ROTATION_NONE) {
  309. // Clear rotation.
  310. t.basis = Basis();
  311. } else if (p_rotation_mode == PathFollow3D::ROTATION_ORIENTED) {
  312. Vector3 tangent = -t.basis.get_column(2);
  313. // Y-axis points up by default.
  314. t.basis = Basis::looking_at(tangent);
  315. } else {
  316. // Lock some euler axes.
  317. Vector3 euler = t.basis.get_euler_normalized(EulerOrder::YXZ);
  318. if (p_rotation_mode == PathFollow3D::ROTATION_Y) {
  319. // Only Y-axis allowed.
  320. euler[0] = 0;
  321. euler[2] = 0;
  322. } else if (p_rotation_mode == PathFollow3D::ROTATION_XY) {
  323. // XY allowed.
  324. euler[2] = 0;
  325. }
  326. Basis locked = Basis::from_euler(euler, EulerOrder::YXZ);
  327. t.basis = locked;
  328. }
  329. return t;
  330. }
  331. void PathFollow3D::_bind_methods() {
  332. ClassDB::bind_method(D_METHOD("set_progress", "progress"), &PathFollow3D::set_progress);
  333. ClassDB::bind_method(D_METHOD("get_progress"), &PathFollow3D::get_progress);
  334. ClassDB::bind_method(D_METHOD("set_h_offset", "h_offset"), &PathFollow3D::set_h_offset);
  335. ClassDB::bind_method(D_METHOD("get_h_offset"), &PathFollow3D::get_h_offset);
  336. ClassDB::bind_method(D_METHOD("set_v_offset", "v_offset"), &PathFollow3D::set_v_offset);
  337. ClassDB::bind_method(D_METHOD("get_v_offset"), &PathFollow3D::get_v_offset);
  338. ClassDB::bind_method(D_METHOD("set_progress_ratio", "ratio"), &PathFollow3D::set_progress_ratio);
  339. ClassDB::bind_method(D_METHOD("get_progress_ratio"), &PathFollow3D::get_progress_ratio);
  340. ClassDB::bind_method(D_METHOD("set_rotation_mode", "rotation_mode"), &PathFollow3D::set_rotation_mode);
  341. ClassDB::bind_method(D_METHOD("get_rotation_mode"), &PathFollow3D::get_rotation_mode);
  342. ClassDB::bind_method(D_METHOD("set_cubic_interpolation", "enabled"), &PathFollow3D::set_cubic_interpolation_enabled);
  343. ClassDB::bind_method(D_METHOD("get_cubic_interpolation"), &PathFollow3D::is_cubic_interpolation_enabled);
  344. ClassDB::bind_method(D_METHOD("set_use_model_front", "enabled"), &PathFollow3D::set_use_model_front);
  345. ClassDB::bind_method(D_METHOD("is_using_model_front"), &PathFollow3D::is_using_model_front);
  346. ClassDB::bind_method(D_METHOD("set_loop", "loop"), &PathFollow3D::set_loop);
  347. ClassDB::bind_method(D_METHOD("has_loop"), &PathFollow3D::has_loop);
  348. ClassDB::bind_method(D_METHOD("set_tilt_enabled", "enabled"), &PathFollow3D::set_tilt_enabled);
  349. ClassDB::bind_method(D_METHOD("is_tilt_enabled"), &PathFollow3D::is_tilt_enabled);
  350. ClassDB::bind_static_method("PathFollow3D", D_METHOD("correct_posture", "transform", "rotation_mode"), &PathFollow3D::correct_posture);
  351. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "progress", PROPERTY_HINT_RANGE, "0,10000,0.01,or_less,or_greater,suffix:m"), "set_progress", "get_progress");
  352. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "progress_ratio", PROPERTY_HINT_RANGE, "0,1,0.0001,or_less,or_greater", PROPERTY_USAGE_EDITOR), "set_progress_ratio", "get_progress_ratio");
  353. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "h_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_h_offset", "get_h_offset");
  354. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "v_offset", PROPERTY_HINT_NONE, "suffix:m"), "set_v_offset", "get_v_offset");
  355. ADD_PROPERTY(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ,Oriented"), "set_rotation_mode", "get_rotation_mode");
  356. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_model_front"), "set_use_model_front", "is_using_model_front");
  357. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cubic_interp"), "set_cubic_interpolation", "get_cubic_interpolation");
  358. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop");
  359. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tilt_enabled"), "set_tilt_enabled", "is_tilt_enabled");
  360. BIND_ENUM_CONSTANT(ROTATION_NONE);
  361. BIND_ENUM_CONSTANT(ROTATION_Y);
  362. BIND_ENUM_CONSTANT(ROTATION_XY);
  363. BIND_ENUM_CONSTANT(ROTATION_XYZ);
  364. BIND_ENUM_CONSTANT(ROTATION_ORIENTED);
  365. }
  366. void PathFollow3D::set_progress(real_t p_progress) {
  367. ERR_FAIL_COND(!std::isfinite(p_progress));
  368. if (progress == p_progress) {
  369. return;
  370. }
  371. progress = p_progress;
  372. if (path) {
  373. if (path->get_curve().is_valid()) {
  374. real_t path_length = path->get_curve()->get_baked_length();
  375. if (loop && path_length) {
  376. progress = Math::fposmod(progress, path_length);
  377. if (!Math::is_zero_approx(p_progress) && Math::is_zero_approx(progress)) {
  378. progress = path_length;
  379. }
  380. } else {
  381. progress = CLAMP(progress, 0, path_length);
  382. }
  383. }
  384. update_transform();
  385. }
  386. }
  387. void PathFollow3D::set_h_offset(real_t p_h_offset) {
  388. if (h_offset == p_h_offset) {
  389. return;
  390. }
  391. h_offset = p_h_offset;
  392. update_transform();
  393. }
  394. real_t PathFollow3D::get_h_offset() const {
  395. return h_offset;
  396. }
  397. void PathFollow3D::set_v_offset(real_t p_v_offset) {
  398. if (v_offset == p_v_offset) {
  399. return;
  400. }
  401. v_offset = p_v_offset;
  402. update_transform();
  403. }
  404. real_t PathFollow3D::get_v_offset() const {
  405. return v_offset;
  406. }
  407. real_t PathFollow3D::get_progress() const {
  408. return progress;
  409. }
  410. void PathFollow3D::set_progress_ratio(real_t p_ratio) {
  411. ERR_FAIL_NULL_MSG(path, "Can only set progress ratio on a PathFollow3D that is the child of a Path3D which is itself part of the scene tree.");
  412. ERR_FAIL_COND_MSG(path->get_curve().is_null(), "Can't set progress ratio on a PathFollow3D that does not have a Curve.");
  413. ERR_FAIL_COND_MSG(!path->get_curve()->get_baked_length(), "Can't set progress ratio on a PathFollow3D that has a 0 length curve.");
  414. set_progress(p_ratio * path->get_curve()->get_baked_length());
  415. }
  416. real_t PathFollow3D::get_progress_ratio() const {
  417. if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) {
  418. return get_progress() / path->get_curve()->get_baked_length();
  419. } else {
  420. return 0;
  421. }
  422. }
  423. void PathFollow3D::set_rotation_mode(RotationMode p_rotation_mode) {
  424. if (rotation_mode == p_rotation_mode) {
  425. return;
  426. }
  427. rotation_mode = p_rotation_mode;
  428. update_configuration_warnings();
  429. update_transform();
  430. }
  431. PathFollow3D::RotationMode PathFollow3D::get_rotation_mode() const {
  432. return rotation_mode;
  433. }
  434. void PathFollow3D::set_use_model_front(bool p_use_model_front) {
  435. if (use_model_front == p_use_model_front) {
  436. return;
  437. }
  438. use_model_front = p_use_model_front;
  439. update_transform();
  440. }
  441. bool PathFollow3D::is_using_model_front() const {
  442. return use_model_front;
  443. }
  444. void PathFollow3D::set_loop(bool p_loop) {
  445. if (loop == p_loop) {
  446. return;
  447. }
  448. loop = p_loop;
  449. update_transform();
  450. }
  451. bool PathFollow3D::has_loop() const {
  452. return loop;
  453. }
  454. void PathFollow3D::set_tilt_enabled(bool p_enabled) {
  455. if (tilt_enabled == p_enabled) {
  456. return;
  457. }
  458. tilt_enabled = p_enabled;
  459. update_transform();
  460. }
  461. bool PathFollow3D::is_tilt_enabled() const {
  462. return tilt_enabled;
  463. }