mouse event dont reallocate every frame
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
0ce647635c
commit
cacb20cf49
@ -2137,6 +2137,7 @@ Fix many places where entity position being set on vector fetched from getPositi
|
|||||||
- Fixed skybox placement update
|
- Fixed skybox placement update
|
||||||
Undo getPosition new alloc to lower memory footprint
|
Undo getPosition new alloc to lower memory footprint
|
||||||
Work to reduce allocations
|
Work to reduce allocations
|
||||||
|
Prevent mouse event re-allocation every frame
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -86,6 +86,11 @@ public class ControlHandler {
|
|||||||
*/
|
*/
|
||||||
boolean cameraIsThirdPerson = false;
|
boolean cameraIsThirdPerson = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private mouse event to prevent re-allocating
|
||||||
|
*/
|
||||||
|
private MouseEvent mouseEvent = new MouseEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of window strings that would block main game controls
|
* The list of window strings that would block main game controls
|
||||||
*/
|
*/
|
||||||
@ -245,7 +250,7 @@ public class ControlHandler {
|
|||||||
this.mouseState.setDeltaY(this.mouseState.getLastY() - this.mouseState.getCurrentY());
|
this.mouseState.setDeltaY(this.mouseState.getLastY() - this.mouseState.getCurrentY());
|
||||||
float xoffset = (float) (this.mouseState.getCurrentX() - this.mouseState.getLastX());
|
float xoffset = (float) (this.mouseState.getCurrentX() - this.mouseState.getLastX());
|
||||||
float yoffset = (float) (this.mouseState.getLastY() - this.mouseState.getCurrentY());
|
float yoffset = (float) (this.mouseState.getLastY() - this.mouseState.getCurrentY());
|
||||||
MouseEvent currentMouseEvent = new MouseEvent(
|
this.mouseEvent.set(
|
||||||
(int)this.mouseState.getCurrentX(),
|
(int)this.mouseState.getCurrentX(),
|
||||||
(int)this.mouseState.getCurrentY(),
|
(int)this.mouseState.getCurrentY(),
|
||||||
(int)this.mouseState.getLastX(),
|
(int)this.mouseState.getLastX(),
|
||||||
@ -311,7 +316,7 @@ public class ControlHandler {
|
|||||||
} break;
|
} break;
|
||||||
case MOUSE_MOVEMENT: {
|
case MOUSE_MOVEMENT: {
|
||||||
if(mouseMoveEvent){
|
if(mouseMoveEvent){
|
||||||
control.onMove(this.mouseState,currentMouseEvent);
|
control.onMove(this.mouseState,this.mouseEvent);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case MOUSE_SCROLL: {
|
case MOUSE_SCROLL: {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public class MouseEvent implements Event {
|
|||||||
boolean button1;
|
boolean button1;
|
||||||
boolean button2;
|
boolean button2;
|
||||||
|
|
||||||
public MouseEvent(int currentX,int currentY,int previousX,int previousY,int deltaX,int deltaY,boolean button1,boolean button2){
|
public void set(int currentX,int currentY,int previousX,int previousY,int deltaX,int deltaY,boolean button1,boolean button2){
|
||||||
this.currentX = currentX;
|
this.currentX = currentX;
|
||||||
this.currentY = currentY;
|
this.currentY = currentY;
|
||||||
this.previousX = previousX;
|
this.previousX = previousX;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user