mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-10 16:03:15 -04:00
Avoid using doubles for input handler ticking
This commit is contained in:
parent
47c4e91443
commit
c892cfb5dc
@ -685,7 +685,7 @@ static CC_INLINE void Game_DrawFrame(float delta, float t) {
|
|||||||
if (!Gui_GetBlocksWorld()) {
|
if (!Gui_GetBlocksWorld()) {
|
||||||
Camera.Active->GetPickedBlock(&Game_SelectedPos); /* TODO: only pick when necessary */
|
Camera.Active->GetPickedBlock(&Game_SelectedPos); /* TODO: only pick when necessary */
|
||||||
Camera_KeyLookUpdate(delta);
|
Camera_KeyLookUpdate(delta);
|
||||||
InputHandler_Tick();
|
InputHandler_Tick(delta);
|
||||||
|
|
||||||
if (Game_Anaglyph3D) {
|
if (Game_Anaglyph3D) {
|
||||||
Render3D_Anaglyph(delta, t);
|
Render3D_Anaglyph(delta, t);
|
||||||
|
@ -50,7 +50,7 @@ static void CompileFetchShader(GX2FetchShader* shader, const GX2AttribStream* at
|
|||||||
uint32_t size = GX2CalcFetchShaderSizeEx(numAttribs,
|
uint32_t size = GX2CalcFetchShaderSizeEx(numAttribs,
|
||||||
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
||||||
GX2_TESSELLATION_MODE_DISCRETE);
|
GX2_TESSELLATION_MODE_DISCRETE);
|
||||||
void* program = MEMAllocFromDefaultHeapEx(size, GX2_SHADER_PROGRAM_ALIGNMENT); // TODO memalign
|
void* program = memalign(GX2_SHADER_PROGRAM_ALIGNMENT, size);
|
||||||
|
|
||||||
GX2InitFetchShaderEx(shader, program, numAttribs, attribs,
|
GX2InitFetchShaderEx(shader, program, numAttribs, attribs,
|
||||||
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
GX2_FETCH_SHADER_TESSELLATION_NONE,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
static cc_bool input_buttonsDown[3];
|
static cc_bool input_buttonsDown[3];
|
||||||
static int input_pickingId = -1;
|
static int input_pickingId = -1;
|
||||||
static double input_lastClick;
|
static float input_deltaAcc;
|
||||||
static float input_fovIndex = -1.0f;
|
static float input_fovIndex = -1.0f;
|
||||||
#ifdef CC_BUILD_WEB
|
#ifdef CC_BUILD_WEB
|
||||||
static cc_bool suppressEscape;
|
static cc_bool suppressEscape;
|
||||||
@ -273,7 +273,7 @@ static void MouseStateUpdate(int button, cc_bool pressed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void MouseStatePress(int button) {
|
static void MouseStatePress(int button) {
|
||||||
input_lastClick = Game.Time;
|
input_deltaAcc = 0;
|
||||||
input_pickingId = -1;
|
input_pickingId = -1;
|
||||||
MouseStateUpdate(button, true);
|
MouseStateUpdate(button, true);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ static void MouseStateRelease(int button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler_OnScreensChanged(void) {
|
void InputHandler_OnScreensChanged(void) {
|
||||||
input_lastClick = Game.Time;
|
input_deltaAcc = 0;
|
||||||
input_pickingId = -1;
|
input_pickingId = -1;
|
||||||
if (!Gui.InputGrab) return;
|
if (!Gui.InputGrab) return;
|
||||||
|
|
||||||
@ -456,19 +456,18 @@ static void InputHandler_PickBlock(void) {
|
|||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
static cc_bool AnyBlockTouches(void);
|
static cc_bool AnyBlockTouches(void);
|
||||||
#endif
|
#endif
|
||||||
void InputHandler_Tick(void) {
|
void InputHandler_Tick(float delta) {
|
||||||
cc_bool left, middle, right;
|
cc_bool left, middle, right;
|
||||||
double now, delta;
|
|
||||||
|
|
||||||
|
input_deltaAcc += delta;
|
||||||
if (Gui.InputGrab) return;
|
if (Gui.InputGrab) return;
|
||||||
now = Game.Time;
|
|
||||||
delta = now - input_lastClick;
|
|
||||||
|
|
||||||
if (delta < 0.2495) return; /* 4 times per second */
|
/* Only tick 4 times per second when held down */
|
||||||
|
if (input_deltaAcc < 0.2495f) return;
|
||||||
/* NOTE: 0.2495 is used instead of 0.25 to produce delta time */
|
/* NOTE: 0.2495 is used instead of 0.25 to produce delta time */
|
||||||
/* values slightly closer to the old code which measured */
|
/* values slightly closer to the old code which measured */
|
||||||
/* elapsed time using DateTime_CurrentUTC_MS() instead */
|
/* elapsed time using DateTime_CurrentUTC_MS() instead */
|
||||||
input_lastClick = now;
|
input_deltaAcc = 0;
|
||||||
|
|
||||||
left = input_buttonsDown[MOUSE_LEFT];
|
left = input_buttonsDown[MOUSE_LEFT];
|
||||||
middle = input_buttonsDown[MOUSE_MIDDLE];
|
middle = input_buttonsDown[MOUSE_MIDDLE];
|
||||||
@ -785,10 +784,10 @@ static void OnPointerDown(void* obj, int idx) {
|
|||||||
struct Screen* s;
|
struct Screen* s;
|
||||||
int i, x, y, mask;
|
int i, x, y, mask;
|
||||||
|
|
||||||
/* Always set last click time, otherwise quickly tapping */
|
/* Always reset held time, otherwise quickly tapping */
|
||||||
/* sometimes triggers a 'delete' in InputHandler_Tick, */
|
/* sometimes triggers a 'delete' in InputHandler_Tick, */
|
||||||
/* and then another 'delete' in CheckBlockTap. */
|
/* and then another 'delete' in CheckBlockTap. */
|
||||||
input_lastClick = Game.Time;
|
input_deltaAcc = 0;
|
||||||
|
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
if (Input_TouchMode && !(touches[idx].type & TOUCH_TYPE_GUI)) return;
|
if (Input_TouchMode && !(touches[idx].type & TOUCH_TYPE_GUI)) return;
|
||||||
|
@ -50,7 +50,7 @@ void StoredHotkeys_Add(int trigger, cc_uint8 modifiers, cc_bool moreInput, const
|
|||||||
|
|
||||||
cc_bool InputHandler_SetFOV(int fov);
|
cc_bool InputHandler_SetFOV(int fov);
|
||||||
cc_bool Input_HandleMouseWheel(float delta);
|
cc_bool Input_HandleMouseWheel(float delta);
|
||||||
void InputHandler_Tick(void);
|
void InputHandler_Tick(float delta);
|
||||||
void InputHandler_OnScreensChanged(void);
|
void InputHandler_OnScreensChanged(void);
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ void DateTime_CurrentLocal(struct cc_datetime* t) {
|
|||||||
*--------------------------------------------------------Stopwatch--------------------------------------------------------*
|
*--------------------------------------------------------Stopwatch--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
cc_uint64 Stopwatch_Measure(void) {
|
cc_uint64 Stopwatch_Measure(void) {
|
||||||
return OSGetSystemTime(); // TODO OSGetSystemTick ??
|
return OSGetSystemTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user