Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bullet 3 physics to godot 4 #47507

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,9 @@
The default angular damp in 3D.
[b]Note:[/b] Good values are in the range [code]0[/code] to [code]1[/code]. At value [code]0[/code] objects will keep moving with the same velocity. Values greater than [code]1[/code] will aim to reduce the velocity to [code]0[/code] in less than a second e.g. a value of [code]2[/code] will aim to reduce the velocity to [code]0[/code] in half a second. A value equal to or greater than the physics frame rate ([member ProjectSettings.physics/common/physics_fps], [code]60[/code] by default) will bring the object to a stop in one iteration.
</member>
<member name="physics/3d/active_soft_world" type="bool" setter="" getter="" default="true">
Active soft world (only for bullet engine)
</member>
<member name="physics/3d/default_gravity" type="float" setter="" getter="" default="9.8">
The default gravity strength in 3D.
[b]Note:[/b] This property is only read when the project starts. To change the default gravity at runtime, use the following code sample:
Expand Down
8 changes: 6 additions & 2 deletions modules/bullet/area_bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <btBulletCollisionCommon.h>

/**
@author AndreaCatania
@author AndreaCatania && sboronczyk
*/

AreaBullet::AreaBullet() :
Expand All @@ -59,9 +59,13 @@ AreaBullet::AreaBullet() :

AreaBullet::~AreaBullet() {
// signal are handled by godot, so just clear without notify
//thread issue

for (int i = overlappingObjects.size() - 1; 0 <= i; --i) {
overlappingObjects[i].object->on_exit_area(this);
OverlappingObjectData &otherObj = overlappingObjects.write[i];
otherObj.object->on_exit_area(this);
}

}

void AreaBullet::dispatch_callbacks() {
Expand Down
6 changes: 5 additions & 1 deletion modules/bullet/area_bullet.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "space_bullet.h"

/**
@author AndreaCatania
@author AndreaCatania && sboronczyk
*/

class btGhostObject;
Expand Down Expand Up @@ -85,6 +85,7 @@ class AreaBullet : public RigidCollisionObjectBullet {
btGhostObject *btGhost = nullptr;
Vector<OverlappingObjectData> overlappingObjects;
bool monitorable = true;
int priority;

PhysicsServer3D::AreaSpaceOverrideMode spOv_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
bool spOv_gravityPoint = false;
Expand Down Expand Up @@ -139,6 +140,9 @@ class AreaBullet : public RigidCollisionObjectBullet {
_FORCE_INLINE_ void set_spOv_priority(int p_priority) { spOv_priority = p_priority; }
_FORCE_INLINE_ int get_spOv_priority() { return spOv_priority; }

_FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; }
_FORCE_INLINE_ int get_priority() const { return priority; }

virtual void main_shape_changed();
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
Expand Down
Loading