Commit 41afde90745b3ddfa05c027c6522af1c9e8bf0e2
1 parent
549cce45
Fix Svace/Coverity issue (convert from uint16_t to float and int)
Change-Id: I065e6331de68119313a0a1f62e268e726f78d97d Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
Showing
1 changed file
with
8 additions
and
8 deletions
examples/chipmunk-physics/physics-demo-controller.cpp
| ... | ... | @@ -170,8 +170,8 @@ public: |
| 170 | 170 | |
| 171 | 171 | // Ball area = 2*PI*26^2 ~= 6.28*26*26 ~= 5400 |
| 172 | 172 | // Fill top quarter of the screen... |
| 173 | - int numBalls = 10 + windowSize.GetWidth() * windowSize.GetHeight() / 20000; | |
| 174 | - for(int i = 0; i < numBalls; ++i) | |
| 173 | + uint32_t numBalls = 10u + static_cast<uint32_t>(windowSize.GetWidth()) * static_cast<uint32_t>(windowSize.GetHeight()) / 20000; | |
| 174 | + for(uint32_t i = 0; i < numBalls; ++i) | |
| 175 | 175 | { |
| 176 | 176 | mBalls.push_back(CreateBall(space)); |
| 177 | 177 | } |
| ... | ... | @@ -241,7 +241,7 @@ public: |
| 241 | 241 | cpShapeSetFriction(logoShape, 0.9); |
| 242 | 242 | cpShapeSetElasticity(logoShape, 0.0); |
| 243 | 243 | Window::WindowSize windowSize = mWindow.GetSize(); |
| 244 | - Vector3 daliPos(0, -windowSize.GetHeight() / 2 + logoSize.height * 1.3, 0); | |
| 244 | + Vector3 daliPos(0, -static_cast<float>(windowSize.GetHeight()) / 2 + logoSize.height * 1.3f, 0); | |
| 245 | 245 | Vector3 physPos = mPhysicsAdaptor.TranslateToPhysicsSpace(daliPos); |
| 246 | 246 | cpBodySetPosition(logoBody, cpv(physPos.x, physPos.y)); |
| 247 | 247 | |
| ... | ... | @@ -299,8 +299,8 @@ public: |
| 299 | 299 | // Image is 326x171; center of letter is guessed; each image contains only 1 image. |
| 300 | 300 | // Position the letters into the window |
| 301 | 301 | |
| 302 | - float cellW = (windowSize.GetWidth() - 170) / 4; | |
| 303 | - float cellC = -windowSize.GetWidth() * 0.5f + cellW * (0.5f + index); | |
| 302 | + float cellW = (static_cast<float>(windowSize.GetWidth()) - 170) / 4; | |
| 303 | + float cellC = -static_cast<float>(windowSize.GetWidth()) * 0.5f + cellW * (0.5f + index); | |
| 304 | 304 | float x = 85 + cellC; // - 61.0f; |
| 305 | 305 | Vector3 physPos = mPhysicsAdaptor.TranslateToPhysicsSpace(Vector3(x, 0, 0.0f)); |
| 306 | 306 | |
| ... | ... | @@ -343,8 +343,8 @@ public: |
| 343 | 343 | void CreateBounds(cpSpace* space, Window::WindowSize size) |
| 344 | 344 | { |
| 345 | 345 | // We're working in physics space here - coords are: origin: bottom left, +ve Y: up |
| 346 | - int xBound = size.GetWidth(); | |
| 347 | - int yBound = size.GetHeight(); | |
| 346 | + int32_t xBound = static_cast<int32_t>(static_cast<uint32_t>(size.GetWidth())); | |
| 347 | + int32_t yBound = static_cast<int32_t>(static_cast<uint32_t>(size.GetHeight())); | |
| 348 | 348 | |
| 349 | 349 | cpBody* staticBody = cpSpaceGetStaticBody(space); |
| 350 | 350 | |
| ... | ... | @@ -435,7 +435,7 @@ public: |
| 435 | 435 | auto screenCoords = touch.GetScreenPosition(0); |
| 436 | 436 | // In this demo, physics space is equivalent to screen space with y inverted |
| 437 | 437 | auto windowSize = mWindow.GetSize(); |
| 438 | - Vector3 rayPhysicsOrigin(screenCoords.x, windowSize.GetHeight() - screenCoords.y, 0.0f); | |
| 438 | + Vector3 rayPhysicsOrigin(screenCoords.x, static_cast<float>(windowSize.GetHeight()) - screenCoords.y, 0.0f); | |
| 439 | 439 | |
| 440 | 440 | switch(state) |
| 441 | 441 | { | ... | ... |