Merge pull request #2084 from QuantumCoderQC/29RBFix

Blender 2.9 Fix Exporter and conversions for Physics World
This commit is contained in:
Lubos Lenco 2021-01-07 11:49:58 +01:00 committed by GitHub
commit 833b513969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -53,7 +53,6 @@ class PhysicsWorld extends Trait {
public var rbMap: Map<Int, RigidBody>;
public var conMap: Map<Int, PhysicsConstraint>;
public var timeScale = 1.0;
var timeStep = 1 / 60;
var maxSteps = 1;
public var solverIterations = 10;
public var hitPointWorld = new Vec4();
@ -68,7 +67,7 @@ class PhysicsWorld extends Trait {
public static var physTime = 0.0;
#end
public function new(timeScale = 1.0, timeStep = 1 / 60, solverIterations = 10) {
public function new(timeScale = 1.0, maxSteps = 10, solverIterations = 10) {
super();
if (nullvec) {
@ -82,8 +81,7 @@ class PhysicsWorld extends Trait {
sceneRemoved = false;
this.timeScale = timeScale;
this.timeStep = timeStep;
maxSteps = timeStep < 1 / 60 ? 10 : 1;
this.maxSteps = maxSteps;
this.solverIterations = solverIterations;
// First scene
@ -270,7 +268,13 @@ class PhysicsWorld extends Trait {
if (preUpdates != null) for (f in preUpdates) f();
world.stepSimulation(timeStep, maxSteps, t);
//Bullet physics fixed timescale
var fixedTime = 1.0 / 60;
//This condition must be satisfied to not loose time
var currMaxSteps = t < (fixedTime * maxSteps) ? maxSteps : 1;
world.stepSimulation(t, currMaxSteps, fixedTime);
updateContacts();
for (rb in rbMap) @:privateAccess rb.physicsUpdate();

View file

@ -2596,7 +2596,7 @@ class ArmoryExporter:
rbw = self.scene.rigidbody_world
if rbw is not None and rbw.enabled:
out_trait['parameters'] = [str(rbw.time_scale), str(1 / rbw.steps_per_second), str(rbw.solver_iterations)]
out_trait['parameters'] = [str(rbw.time_scale), str(rbw.substeps_per_frame), str(rbw.solver_iterations)]
self.output['traits'].append(out_trait)