mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
more perf
This commit is contained in:
parent
585b50a908
commit
f2a7eb70b8
5 changed files with 51 additions and 38 deletions
|
|
@ -1612,8 +1612,8 @@ class Marble extends GameObject {
|
|||
tdiff = diff;
|
||||
}
|
||||
var expectedPos = finalPosData.position;
|
||||
// var newPos = expectedPos;
|
||||
var newPos = nudgeToContacts(expectedPos, _radius, finalPosData.foundContacts, finalPosData.foundMarbles);
|
||||
var newPos = expectedPos;
|
||||
// var newPos = nudgeToContacts(expectedPos, _radius, finalPosData.foundContacts, finalPosData.foundMarbles);
|
||||
|
||||
if (this.velocity.lengthSq() > 1e-8) {
|
||||
var posDiff = newPos.sub(expectedPos);
|
||||
|
|
|
|||
|
|
@ -94,14 +94,16 @@ class ProfilerUI {
|
|||
lastSentMove = @:privateAccess Net.clientConnection.moveManager.queuedMoves[Net.clientConnection.moveManager.queuedMoves.length - 1].id;
|
||||
}
|
||||
|
||||
instance.networkStats.text = 'Client World Ticks: ${MarbleGame.instance.world.timeState.ticks}\n'
|
||||
+ 'Client Marble Ticks: ${@:privateAccess MarbleGame.instance.world.marble.serverTicks}\n'
|
||||
+ 'Server Ticks: ${@:privateAccess MarbleGame.instance.world.lastMoves.myMarbleUpdate.serverTicks}\n'
|
||||
+ 'Client Move Queue Size: ${Net.isClient ? Net.clientConnection.getQueuedMovesLength() : 0}\n'
|
||||
+ 'Server Move Queue Size: ${Net.isClient ? @:privateAccess MarbleGame.instance.world.lastMoves.myMarbleUpdate.moveQueueSize : 0}\n'
|
||||
+ 'Last Sent Move: ${Net.isClient ? lastSentMove : 0}\n'
|
||||
+ 'Last Ack Move: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.lastAckMoveId : 0}\n'
|
||||
+ 'Move Ack RTT: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.ackRTT : 0}';
|
||||
if (Net.isClient) {
|
||||
instance.networkStats.text = 'Client World Ticks: ${MarbleGame.instance.world.timeState.ticks}\n'
|
||||
+ 'Client Marble Ticks: ${@:privateAccess MarbleGame.instance.world.marble.serverTicks}\n'
|
||||
+ 'Server Ticks: ${@:privateAccess MarbleGame.instance.world.lastMoves.myMarbleUpdate.serverTicks}\n'
|
||||
+ 'Client Move Queue Size: ${Net.isClient ? Net.clientConnection.getQueuedMovesLength() : 0}\n'
|
||||
+ 'Server Move Queue Size: ${Net.isClient ? @:privateAccess MarbleGame.instance.world.lastMoves.myMarbleUpdate.moveQueueSize : 0}\n'
|
||||
+ 'Last Sent Move: ${Net.isClient ? lastSentMove : 0}\n'
|
||||
+ 'Last Ack Move: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.lastAckMoveId : 0}\n'
|
||||
+ 'Move Ack RTT: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.ackRTT : 0}';
|
||||
}
|
||||
} else {
|
||||
instance.networkStats.text = "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class CollisionWorld {
|
|||
public var entities:Array<CollisionEntity> = [];
|
||||
public var dynamicEntities:Array<CollisionEntity> = [];
|
||||
public var dynamicOctree:Octree;
|
||||
public var sap:SAP;
|
||||
|
||||
public var marbleEntities:Array<SphereCollisionEntity> = [];
|
||||
|
||||
|
|
@ -31,7 +30,6 @@ class CollisionWorld {
|
|||
this.octree = new Octree();
|
||||
this.dynamicOctree = new Octree();
|
||||
this.staticWorld = new CollisionEntity(null);
|
||||
this.sap = new SAP();
|
||||
}
|
||||
|
||||
public function sphereIntersection(spherecollision:SphereCollisionEntity, timeState:TimeState):SphereIntersectionResult {
|
||||
|
|
@ -46,40 +44,43 @@ class CollisionWorld {
|
|||
box.transform(rotQuat.toMatrix());
|
||||
box.offset(position.x, position.y, position.z);
|
||||
// box.addSpherePos(position.x + velocity.x * timeState.dt, position.y + velocity.y * timeState.dt, position.z + velocity.z * timeState.dt, radius);
|
||||
// var intersections = this.octree.boundingSearch(box);
|
||||
var intersections = this.octree.boundingSearch(box);
|
||||
|
||||
// var intersections = this.rtree.search([box.xMin, box.yMax, box.zMin], [box.xSize, box.ySize, box.zSize]);
|
||||
|
||||
var contacts = [];
|
||||
var foundEntities = [];
|
||||
|
||||
// for (obj in intersections) {
|
||||
// var entity:CollisionEntity = cast obj;
|
||||
for (obj in intersections) {
|
||||
var entity:CollisionEntity = cast obj;
|
||||
|
||||
// foundEntities.push(entity);
|
||||
// if (entity.go.isCollideable) {
|
||||
// contacts = contacts.concat(entity.sphereIntersection(spherecollision, timeState));
|
||||
// }
|
||||
// }
|
||||
|
||||
sap.recompute();
|
||||
var sapCollisions = sap.getIntersections(spherecollision);
|
||||
for (obj in sapCollisions) {
|
||||
if (obj.boundingBox.collide(box) && obj.go.isCollideable) {
|
||||
contacts = contacts.concat(obj.sphereIntersection(spherecollision, timeState));
|
||||
foundEntities.push(entity);
|
||||
if (entity.go.isCollideable) {
|
||||
contacts = contacts.concat(entity.sphereIntersection(spherecollision, timeState));
|
||||
}
|
||||
}
|
||||
|
||||
// contacts = contacts.concat(this.staticWorld.sphereIntersection(spherecollision, timeState));
|
||||
|
||||
// var dynSearch = dynamicOctree.boundingSearch(box).map(x -> cast(x, CollisionEntity));
|
||||
// for (obj in dynSearch) {
|
||||
// if (obj != spherecollision) {
|
||||
// if (obj.boundingBox.collide(box) && obj.go.isCollideable)
|
||||
// if (marbleEntities.length > 1) {
|
||||
// marbleSap.recompute();
|
||||
// var sapCollisions = marbleSap.getIntersections(spherecollision);
|
||||
// for (obj in sapCollisions) {
|
||||
// if (obj.go.isCollideable) {
|
||||
// contacts = contacts.concat(obj.sphereIntersection(spherecollision, timeState));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// contacts = contacts.concat(this.staticWorld.sphereIntersection(spherecollision, timeState));
|
||||
|
||||
var dynSearch = dynamicOctree.boundingSearch(box);
|
||||
for (obj in dynSearch) {
|
||||
if (obj != spherecollision) {
|
||||
var col = cast(obj, CollisionEntity);
|
||||
if (col.boundingBox.collide(box) && col.go.isCollideable)
|
||||
contacts = contacts.concat(col.sphereIntersection(spherecollision, timeState));
|
||||
}
|
||||
}
|
||||
|
||||
// for (marb in marbleEntities) {
|
||||
// if (marb != spherecollision) {
|
||||
// if (spherecollision.go.isCollideable) {
|
||||
|
|
@ -145,7 +146,6 @@ class CollisionWorld {
|
|||
public function addEntity(entity:CollisionEntity) {
|
||||
this.octree.insert(entity);
|
||||
this.entities.push(entity);
|
||||
this.sap.addEntity(entity);
|
||||
|
||||
// this.rtree.insert([entity.boundingBox.xMin, entity.boundingBox.yMin, entity.boundingBox.zMin],
|
||||
// [entity.boundingBox.xSize, entity.boundingBox.ySize, entity.boundingBox.zSize], entity);
|
||||
|
|
@ -163,7 +163,6 @@ class CollisionWorld {
|
|||
this.dynamicEntities.push(entity);
|
||||
this.dynamicOctree.insert(entity);
|
||||
this.dynamicEntitySet.set(entity, true);
|
||||
this.sap.addEntity(entity);
|
||||
}
|
||||
|
||||
public function removeMovingEntity(entity:CollisionEntity) {
|
||||
|
|
@ -171,7 +170,6 @@ class CollisionWorld {
|
|||
}
|
||||
|
||||
public function updateTransform(entity:CollisionEntity) {
|
||||
this.sap.update(entity);
|
||||
if (!dynamicEntitySet.exists(entity)) {
|
||||
this.octree.update(entity);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ class SphereCollisionEntity extends CollisionEntity {
|
|||
public override function generateBoundingBox() {
|
||||
var boundingBox = new Bounds();
|
||||
var pos = transform.getPosition();
|
||||
boundingBox.addSpherePos(pos.x, pos.y, pos.z, radius);
|
||||
boundingBox.transform3x3(transform);
|
||||
boundingBox.addSpherePos(0, 0, 0, radius);
|
||||
boundingBox.transform(transform);
|
||||
|
||||
this.boundingBox = boundingBox;
|
||||
|
||||
if (Debug.drawBounds) {
|
||||
|
|
|
|||
|
|
@ -19,10 +19,14 @@ class CubemapRenderer {
|
|||
var scene:Scene;
|
||||
var nextFaceToRender:Int;
|
||||
var facesPerRender:Int = 2;
|
||||
var updateFps:Float = 360.0;
|
||||
var lastRenderTime:Float = 0;
|
||||
var usingSky:Bool = false;
|
||||
|
||||
public function new(scene:Scene, sky:Sky, useSky = false) {
|
||||
this.scene = scene;
|
||||
this.sky = sky;
|
||||
this.usingSky = useSky;
|
||||
if (useSky)
|
||||
this.cubemap = sky.cubemap;
|
||||
else {
|
||||
|
|
@ -35,10 +39,18 @@ class CubemapRenderer {
|
|||
}
|
||||
|
||||
public function render(e:Engine) {
|
||||
if (usingSky)
|
||||
return;
|
||||
var start = haxe.Timer.stamp();
|
||||
if (start - lastRenderTime > 1.0 / updateFps) {
|
||||
lastRenderTime = start;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var scenecam = scene.camera;
|
||||
scene.camera = camera;
|
||||
|
||||
var start = haxe.Timer.stamp();
|
||||
var renderedFaces = 0;
|
||||
Renderer.cubemapPass = true;
|
||||
for (i in 0...facesPerRender) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue