Skip to content

Discuss about rvx, rvy in collection-map.js #99

Open

Description

@finscn

Discuss about rvx, rvy in collection-map.js

there is a function with arguments named rvx, rvy , What do they mean? what's the full name ?

_traceStep: function( res, x, y, vx, vy, width, height, rvx, rvy, step ) {


the _traceStep() be called with vx & vy

this._traceStep( res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i );

Why do you pass vx , vy ? in my opinion , at line 44 , It should pass sx ,sy


the function _traceStep has arguments rvx, rvy , and pass them into _checkTileDef()

this._checkTileDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY)

(t > 1 && this._checkTileDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)) // slope?

this._checkTileDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY) ) {

(t > 1 && this._checkTileDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)) // slope?

Why do you pass rvx , rvy ? in my opinion , at line 44 , It should pass vx ,vy.


I post a PR , Just for comparing the differences in the code

https://github.com/phoboslab/Impact/pull/100/files

If change the code to my version, will there be any problems?

Activity

  1. added a commit that references this issue on Mar 25, 2025
  2. Joncom commented on Mar 25, 2025

    @Joncom
    Collaborator
  3. Joncom commented on Mar 25, 2025

    @Joncom
    Collaborator
  4. finscn commented on Mar 26, 2025

    @finscn
    Author

    Regarding your pull request, the _traceStep function takes 10 arguments, so I don't know why you're deleting arguments from your calls. You're passing too few arguments (only 8). Why are you doing that?

    because I think rvx rvy is useless , I removed them from _traceStep()'s definition

  5. Joncom commented on Mar 26, 2025

    @Joncom
    Collaborator
  6. phoboslab commented on Mar 26, 2025

    @phoboslab
    Owner

    rvx and rvy ist the "real velocity".

    _traceStep is called like this:

    var sx = vx / steps;
    var sy = vy / steps;
    for( var i = 0; i < steps && (sx || sy); i++ ) {
    this._traceStep( res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i );

    This is passing the velocity for one step (sx, sy named vx, vy in _traceStep) and the real/full velocity of the object (vx, vy named rvx, rvy in _traceStep). The real velocity is not needed for collision detection, but later (in checkTileDef) for resolving the collision.

    Simple example: you hit the ground at an angle. The resolved y position will be the impact position, the x position however will incorporate the x velocity, essentially sliding you over the ground. Here the real x velocity is needed, not the x velocity for just one step of collision detection.

  7. finscn commented on Mar 27, 2025

    @finscn
    Author

    @phoboslab thanks .
    but if use real/full velocity , the target point ( x+ rvy , y+ rvy) or it's pedal may be out of the slope-tile's bounding .

    Image

    should we use the red point ?

  8. Huaian666 commented on Jun 5, 2026

    @Huaian666
  9. Huaian666 commented on Jun 6, 2026

    @Huaian666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions