Skip to content

Fix animation duration calculation #19221

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

Merged
merged 1 commit into from
Nov 30, 2018

Conversation

zeeker999
Copy link

The duration of action will be miscalculated when float abs(float)
is unavailble, replacing it with std::abs fixes the issue.

The duration of action will be miscalculated when float abs(float)
is unavailble, replacing it with std::abs fixes the issue.
@PatriceJiang
Copy link
Contributor

when float abs(float) is unavailable

Could you please provide more info about how would this occur? @LuoJinghua

@zeeker999 zeeker999 closed this Nov 29, 2018
@zeeker999 zeeker999 reopened this Nov 29, 2018
@zeeker999
Copy link
Author

I'm sorry, I accidently closed the pull request.

when float abs(float) is unavailable

Could you please provide more info about how would this occur? @LuoJinghua

assume |d| < 1.0f and float abs(float) is absent,

_duration = abs(d) <= MATH_EPSILON ? MATH_EPSILON : d

will evaluate to

MATH_EPSILON

which is wrong, it should be d instead.

There is no float abs(float) in stdlib.h1 at least on linux.

  #include <stdlib.h>

  int abs(int j);

@PatriceJiang PatriceJiang merged commit ed2eab5 into cocos2d:v3 Nov 30, 2018
@PatriceJiang
Copy link
Contributor

It dose trigger a compile warning message on Linux with clang++.

stevetranby added a commit to stevetranby/cocos2d-x that referenced this pull request Dec 3, 2018
* commit 'ed2eab52973eb614e14f6680b9c0bbd315b017a5':
  Fix animation duration calculation (cocos2d#19221)
  Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (cocos2d#19212)
  Switch travis CI to xenial (cocos2d#19207)
  add testcase for lua downloader binding (cocos2d#19182)

# Conflicts:
#	tests/lua-tests/src/mainMenu.lua
huangwei1024 pushed a commit to huangwei1024/cocos2d-x that referenced this pull request Jun 20, 2019
The duration of action will be miscalculated when float abs(float)
is unavailble, replacing it with std::abs fixes the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants