Skip to content

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

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

Open
finscn opened this issue Mar 25, 2025 · 6 comments
Open

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

finscn opened this issue Mar 25, 2025 · 6 comments

Comments

@finscn
Copy link

finscn commented Mar 25, 2025

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?

finscn added a commit to finscn/Impact that referenced this issue Mar 25, 2025
This is not a real PR
@Joncom
Copy link
Collaborator

Joncom commented Mar 25, 2025 via email

@Joncom
Copy link
Collaborator

Joncom commented Mar 25, 2025 via email

@finscn
Copy link
Author

finscn commented Mar 26, 2025

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

@Joncom
Copy link
Collaborator

Joncom commented Mar 26, 2025 via email

@phoboslab
Copy link
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.

@finscn
Copy link
Author

finscn commented Mar 27, 2025

@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 ?

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

No branches or pull requests

3 participants