Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Jolt 물리 사용하기
소개
Jolt 물리 엔진은 4.4에서 기존 Godot 물리 엔진의 대안으로 추가되었습니다. Jolt는 Jorrit Rouwe가 게임과 VR 애플리케이션에 중점을 두고 개발했습니다. 이전에는 확장으로 사용 가능했지만 이제는 Godot에 내장되어 있습니다. 기본적으로 새 프로젝트에서는 이를 물리 엔진으로 사용합니다.
이제 기존 확장이 유지 관리 모드로 간주됩니다. 즉, 버그 수정이 병합되고 내장 모듈이 확장 기능과 기능 패리티를 가질 때까지 Godot의 새 버전과 호환이 유지된다는 의미입니다. 이 시점에서 누락된 유일한 것은 관련 관절입니다. 이 페이지에서 이에 대해 읽을 수 있습니다. 확장 기능은 여기 GitHub 및 Godot의 자산 라이브러리에서 찾을 수 있습니다.
3D 물리 엔진을 Jolt Physics로 변경하려면 :ref:`Project Settings > Physics > 3D > Physics Engine<class_ProjectSettings_property_physics/3D/Physics_Engine>`를 ``Jolt Physics``로 설정하세요. 그런 다음 저장 및 다시 시작 버튼을 클릭하세요. 편집기가 다시 열리면 이제 3D 장면에서 물리학을 위해 Jolt를 사용해야 합니다.
Godot 물리학과의 주목할만한 차이점
기존 Godot Physics 엔진과 Jolt 사이에는 많은 차이점이 있습니다.
노이즈 속성
3D 조인트 노드의 현재 인터페이스는 Jolt 자체 조인트의 인터페이스와 완전히 일치하지 않습니다. 따라서 지원되지 않는 여러 관절 속성이 있으며, 주로 관절의 소프트 제한 구성과 관련된 속성입니다.
지원되지 않는 속성은 다음과 같습니다:
PinJoint3D:
bias,damping,impulse_clampHingeJoint3D:
bias,softness,relaxationSliderJoint3D:
angular_\*,\*_limit/softness,\*_limit/restitution,\*_limit/dampingConeTwistJoint3D:
bias,relaxation,softnessGeneric6DOFJoint3D:
*_limit_*/softness,*_limit_*/restitution,*_limit_*/damping,*_limit_*/erp
현재 이러한 속성을 기본값 이외의 값으로 설정하면 경고가 표시됩니다.
싱글톤
Godot에서는 두 몸체 관절에 대한 관절 몸체 중 하나를 생략하고 효과적으로 "세계"가 다른 몸체가 되도록 할 수 있습니다. 그러나 본체를 할당한 노드 경로(node_a 대 node_b)는 무시됩니다. Godot Physics는 항상 ``node_a``에 할당한 것처럼 작동하며 ``node_a``는 관절 제한에 대한 참조 프레임을 정의하기 때문에 반전된 제한과 잠재적으로 이상한 제한 모양으로 끝나게 됩니다. 특히 제한이 선형 및 각도 자유도를 모두 허용하는 경우 더욱 그렇습니다.
Jolt는 ``node_b``에 본체를 할당한 것처럼 동작하며 ``node_a``는 "세계"를 나타냅니다. 기존 프로젝트에 대한 호환성이 필요한 경우 이 동작을 전환할 수 있는 :ref:`Physics > Jolt Physics 3D > Joints > World Node<class_ProjectSettings_property_physics/jolt_physics_3d/joints/world_node>`라는 프로젝트 설정이 있습니다.
콜리전 마스크
Jolt(및 기타 유사한 물리 엔진)는 Jolt가 "볼록 반경"이라고 부르는 것을 사용하여 Jolt가 볼록 모양에 의존하는 충돌 감지 유형의 성능과 동작을 개선하는 데 도움을 줍니다. 다른 물리 엔진(Godot 포함)은 대신 이를 "충돌 마진"이라고 부를 수 있습니다. Godot는 이를 모든 Shape3D 파생 클래스에서 margin 속성으로 노출하지만 Godot Physics 자체는 이를 어떤 용도로도 사용하지 않습니다.
(Godot의 문서에 설명된 대로) 다른 엔진에서 이러한 충돌 마진이 때때로 수행하는 작업은 모양 주위에 "쉘"을 효과적으로 추가하여 크기를 약간 늘리는 동시에 가장자리/모서리를 둥글게 만드는 것입니다. 그러나 Jolt에서는 먼저 이러한 여백을 사용하여 모양을 축소한 다음 "쉘"을 적용하여 가장자리/모서리가 비슷하게 둥글게 처리되지만 모양의 크기는 증가하지 않습니다.
이 여백 속성을 수동으로 조정할 필요가 없도록 하기 위해 기본값은 작은 모양에서는 문제가 될 수 있으므로 Jolt 모듈은 실제 여백을 계산하기 위해 모양의 AABB의 가장 작은 축과 곱해지는 :ref:`Physics > Jolt Physics 3D > Collisions > Collision Margin Fraction<class_ProjectSettings_property_physics/jolt_physics_3d/collisions/collision_margin_fraction>`라는 프로젝트 설정을 노출합니다. 대신 모양의 여백 속성이 상한으로 사용됩니다.
이러한 여백은 대부분의 사용 사례에서 어느 정도 투명해야 하지만 때로는 모양 쿼리를 수행할 때 이상한 충돌 법선이 발생할 수 있습니다. 위에서 언급한 프로젝트 설정을 낮추어 ``0.0``로 설정하는 것을 포함하여 이 중 일부를 완화할 수 있지만, 여백이 너무 작으면 이상한 충돌 결과가 발생할 수도 있으므로 일반적으로 권장되지 않습니다.
국제화
바움가르테 안정화는 관통하는 물체를 해결해 닿기만 하는 상태로 밀어내는 방식이다. Godot 물리학에서 이것은 스프링처럼 작동합니다. 이는 몸체가 가속되어 몸체가 오버슛되어 완전히 분리될 수 있음을 의미합니다. Jolt를 사용하면 안정화가 위치에만 적용되고 신체의 속도에는 적용되지 않습니다. 이는 오버슛할 수 없지만 침투를 해결하는 데 시간이 더 오래 걸릴 수 있음을 의미합니다.
이 안정화의 강도는 프로젝트 설정 :ref:`Physics > Jolt Physics 3D > Simulation > Baumgarte Stabilization Factor<class_ProjectSettings_property_physics/jolt_physics_3d/simulation/baumgarte_stabilization_factor>`를 사용하여 조정할 수 있습니다. 이 프로젝트 설정을 ``0.0``로 설정하면 Baumgarte 안정화가 꺼집니다. ``1.0``로 설정하면 1개의 시뮬레이션 단계에서 침투가 해결됩니다. 이는 빠르지만 종종 불안정합니다.
상자 콜리전
Jolt는 고스트 충돌을 완화하기 위해 두 가지 기술을 사용합니다. 즉, 이동 방향에 반대되는 충돌 법선을 초래하는 모양/몸체의 내부 가장자리와의 충돌을 의미합니다.
"활성 가장자리 감지"라고 하는 첫 번째 기술은 ConcavePolygonShape3D 또는 :ref:`class_HeightMapShape3D`의 삼각형 가장자리를 이웃 삼각형에 대한 각도에 따라 "활성" 또는 "비활성"으로 표시합니다. 비활성 가장자리에서 충돌이 발생하면 충돌 법선이 대신 삼각형의 법선으로 대체되어 고스트 충돌의 영향을 줄입니다.
이 활성 가장자리 감지에 대한 각도 임계값은 프로젝트 설정 :ref:`Physics >Jolt Physics 3D > Collisions > Active Edge Threshold<class_ProjectSettings_property_physics/jolt_physics_3d/collisions/active_edge_threshold>`를 통해 구성할 수 있습니다.
"향상된 내부 가장자리 제거"라고 하는 두 번째 기술은 대신 두 본체의 접촉점을 기반으로 가장자리가 활성 상태인지 비활성 상태인지 감지하는 런타임 검사를 추가합니다. 이는 ConcavePolygonShape3D 및 :ref:`class_HeightMapShape3D`와의 충돌뿐만 아니라 동일한 몸체 내의 모든 모양 간의 가장자리에도 적용할 수 있다는 이점이 있습니다.
향상된 내부 가장자리 제거는 Physics >Jolt Physics 3D > Simulation > Use Enhanced Internal Edge Removal, 프로젝트 설정, queries 및 :ref:`motion queries<class_ProjectSettings_property_physics/jolt_physics_3d/motion_queries/use_enhanced_internal_edge_removal>`에 대한 유사한 설정을 사용하여 적용되는 다양한 컨텍스트에 대해 켜거나 끌 수 있습니다.
서로 다른 두 몸체 사이의 고스트 충돌을 처리할 때는 활성 가장자리 감지나 향상된 내부 가장자리 제거가 적용되지 않습니다.
메모리 사용량
Jolt는 시뮬레이션 단계 내에서 임시 할당을 위해 스택 할당자를 사용합니다. 이 스택 할당자는 미리 정해진 양의 메모리를 할당해야 하며, 이는 Physics > Jolt Physics 3D > Limits > Temporary Memory Buffer Size 프로젝트 설정을 사용하여 구성할 수 있습니다.
광선 투사(Ray Cast)하기
intersect_ray() 및 RayCast3D의 결과에 반환된 face_index 속성은 기본적으로 항상 Jolt가 포함된 ``-1``입니다. 프로젝트 설정 :ref:`Physics > Jolt Physics 3D > Queries > Enable Ray Cast Face Index<class_ProjectSettings_property_physics/jolt_physics_3d/queries/enable_ray_cast_face_index>`가 이를 활성화합니다.
이 설정을 활성화하면 :ref:`class_ConcavePolygonShape3D`의 메모리 요구 사항이 약 25% 증가합니다.
KinematicBody
Jolt를 사용할 때 FREEZE_MODE_KINEMATIC<class_RigidBody3D_constant_FREEZE_MODE_KINEMATIC>`로 고정된 :ref:`class_RigidBody3D`는 0이 아닌 :ref:`max_contacts_reported<class_RigidBody3D_property_max_contacts_reported>`를 설정하는 경우에도 성능상의 이유로 기본적으로 다른 정적/운동학적 몸체와의 충돌로 인한 접촉을 보고하지 않습니다. :ref:`class_ConcavePolygonShape3D 또는 :ref:`class_HeightMapShape3D`와 같이 복잡한 정적 지오메트리와 겹치는 다수/큰 운동학적 몸체가 있는 경우, 이를 깨닫지 못한 채 상당한 양의 CPU 성능과 메모리를 낭비하게 될 수 있습니다.
이러한 이유로 이 동작은 프로젝트 설정 :ref:`Physics > Jolt Physics 3D > Simulation > Generate All Kinematic Contacts<class_ProjectSettings_property_physics/jolt_physics_3d/simulation/generate_all_kinematic_contacts>`를 통해 선택적으로 제공됩니다.
접촉 충동
Jolt 내부 제한으로 인해 :ref:`PhysicsDirectBodyState3D.get_contact_impulse()<class_physicsdirectbodystate3d_method_get_contact_impulse>`에서 제공되는 접촉 충격은 접촉 매니폴드 및 충돌체의 속도와 같은 사항을 기반으로 미리 추정됩니다. 이는 보고된 충격이 문제의 두 몸체가 다른 몸체와 충돌하지 않는 경우에만 정확하다는 것을 의미합니다.
Area3D 및 SoftBody3D
Jolt supports the same type of interactions between SoftBody3D and Area3D as Godot Physics, such as the wind and gravity properties found on Area3D. Unlike Godot Physics however, Jolt also supports the various overlap signals and methods found on Area3D, for when a SoftBody3D enters or exits an overlap with it, such as body_entered.
To revert back to the behavior of Godot Physics, where no overlap signals are emitted, you need to configure the area's collision_mask such that there's no overlap with the soft body's collision_layer. You can also filter out any SoftBody3D in the signal connection yourself.
세계경계모양3D
무한한 평면을 표현하기 위한 :ref:`class_WorldBoundaryShape3D`는 Godot Physics와 비교하여 Jolt에서 약간 다르게 구현됩니다. 두 엔진 모두 이 비행기의 유효 크기에 대한 상한선이 있지만 Jolt를 사용할 때는 정밀도 문제를 피하기 위해 이 크기가 훨씬 작습니다.
Physics > Jolt Physics 3D > Limits > World Boundary Shape Size 프로젝트 설정을 사용하여 이 크기를 구성할 수 있습니다.
Godot Jolt 확장 프로그램과의 주목할만한 차이점
내장된 Jolt 모듈은 대체로 Godot Jolt 확장의 직선 포트이지만, 몇 가지 다른 점이 있습니다.
프로젝트 설정
모든 프로젝트 설정이 physics/jolt_3d 범주에서 ``physics/jolt_physics_3d``로 이동되었습니다.
또한 개별 프로젝트 설정의 이름 변경 및 리팩토링도 이루어졌습니다. 여기에는 다음이 포함됩니다.
``sleep/velocity_threshold``는 이제 ``simulation/sleep_velocity_threshold.``입니다.
``sleep/time_threshold``는 이제 ``simulation/sleep_time_threshold.``입니다.
``collisions/use_shape_margins``는 이제 ``collisions/collision_margin_fraction``로 바뀌었습니다. 여기서 값 0은 비활성화하는 것과 같습니다.
``collisions/use_enhanced_internal_edge_removal``는 이제 ``simulation/use_enhanced_internal_edge_removal.``입니다.
``collisions/areas_detect_static_bodies``는 이제 ``simulation/areas_detect_static_bodies.``입니다.
``collisions/report_all_kinematic_contacts``는 이제 ``simulation/generate_all_kinematic_contacts.``입니다.
``collisions/soft_body_point_margin``는 이제 ``simulation/soft_body_point_radius.``입니다.
collisions/body_pair_cache_enabled is now simulation/body_pair_contact_cache_enabled.``collisions/body_pair_cache_distance_threshold``는 ``now simulation/body_pair_contact_cache_distance_threshold.``입니다.
collisions/body_pair_cache_angle_threshold is now simulation/body_pair_contact_cache_angle_threshold.``continuous_cd/movement_threshold``는 이제 ``simulation/continuous_cd_movement_threshold``이지만 백분율 대신 분수로 표시됩니다.
``continuous_cd/max_penetration``는 이제 ``simulation/continuous_cd_max_penetration``이지만 백분율 대신 분수로 표시됩니다.
``kinematics/use_enhanced_internal_edge_removal``는 이제 ``motion_queries/use_enhanced_internal_edge_removal.``입니다.
``kinematics/recovery_iterations``는 이제 ``motion_queries/recovery_iterations``이지만 백분율 대신 분수로 표시됩니다.
``kinematics/recovery_amount``는 이제 ``motion_queries/recovery_amount.``입니다.
``queries/use_legacy_ray_casting``가 제거되었습니다.
``solver/position_iterations``는 이제 ``simulation/position_steps.``입니다.
``solver/velocity_iterations``는 이제 ``simulation/velocity_steps.``입니다.
``solver/position_correction``는 이제 ``simulation/baumgarte_stabilization_factor``이지만 백분율 대신 분수로 표시됩니다.
``solver/active_edge_threshold``는 이제 ``collisions/active_edge_threshold.``입니다.
``solver/bounce_velocity_threshold``는 이제 ``simulation/bounce_velocity_threshold.``입니다.
``solver/contact_speculative_distance``는 이제 ``simulation/speculative_contact_distance.``입니다.
``solver/contact_allowed_penetration``는 이제 ``simulation/penetration_slop.``입니다.
``limits/max_angular_velocity``는 이제 대신 라디안으로 저장됩니다.
``limits/max_temporary_memory``는 이제 ``limits/temporary_memory_buffer_size.``입니다.
노드 만들기
Godot Jolt 확장(JoltPinJoint3D, JoltHingeJoint3D, JoltSliderJoint3D, JoltConeTwistJoint3D 및 JoltGeneric6DOFJoint)에 노출된 조인트 노드는 Jolt 모듈에 포함되지 않았습니다.
스레드
Godot Jolt 확장과 달리 Jolt 모듈에는 Physics > 3D > Run On Separate Thread 프로젝트 설정 지원을 포함하여 스레드 안전성이 있습니다. 그러나 이는 철저하게 테스트되지 않았으므로 실험적인 것으로 간주되어야 합니다.