Jump to content

Rough Terrain (Smooth ?)


Dad72
 Share

Recommended Posts

I have a beginning of result which smooths the edge, but the problem is that it also widening the lower edge. Me, i would like that does not dig into the sand part.

 

By and large the smoothing, must flatten the bumps on the flat (here, this digs), elevate on the hollow (here, this digs also) and round off the corners on the edge (here, ok).

I have modify a can your previous code:

// Smooth vertices                        for (var selectedVertice in this._selectedVertices)            {                var position = this._groundPositions[selectedVertice];                var distance = this._selectedVertices[selectedVertice];                var fullHeight = height * this._invertDirection;                                if (distance < radius * 0.3) {                    position.y += 0;                }                else {                    position.y -= 0.5 * fullHeight * (1.0 - (distance - radius * 0.1) / (radius * 0.9));                }                                    this._groundVerticesPositions[selectedVertice * 3 + 1] = position.y;                this._updateSubdivisions(selectedVertice);            }

Here is the image for that you can see what I want to say:

 

 

Thanks

Link to comment
Share on other sites

Oops I was too fast and I must have done a mistake when simplifying it.

 

First simplification:

if (position.y >= distance) {    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

Second simplification:

if (position.y >= distance) {    position.y -= (fullHeight / 4) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

Third one:

if (position.y >= distance) {    position.y -= (fullHeight / 4) * (1.0 + (radius *0.1 - distance) / (radius * 0.9));}

Fourth one:

if (position.y >= distance) {    position.y -= (fullHeight / 4) * (1.0 + (radius *0.1 / (radius * 0.9) - distance / (radius * 0.9)));}

Fifth one:

if (position.y >= distance) {    position.y -= (fullHeight / 4) * (1.0 + (1/9 - distance / (radius * 0.9)));}

Sixth one:

if (position.y >= distance) {    position.y -= (fullHeight / 4) * (10/9 - distance / (radius * 0.9));}

Argh, I don't get where I'm wrong. Sorry gotta go. Will check that later

Link to comment
Share on other sites

Even the first one? It's the same as

if (position.y < distance) {    position.y += 0;}else {    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

except if position.y is undefined. In your solution, it will set it and in my suggestion it will ignore it.

 

In your code, is it really position.y += 0 or is it position.y = 0 (no plus sign)?

Link to comment
Share on other sites

I really don't understand why you have to do that.

 

y += 0 means y = y + 0 which also means y = y. So this instruction is needless.

 

Thus 

if (position.y < distance) {    position.y += 0;}else {    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

is the same thing as

if (position.y < distance) {    // nothing to do}else {    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

or

if (position.y >= distance) {{    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}
Link to comment
Share on other sites

Yeap the else statment is not needed anymore since !(position.y >= distance) equals to (position.y < distance) and for this case, there is nothing to do.

 

Replace your code:

if (position.y < distance) {    position.y += 0;}else {    position.y -= 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9));}

by what I suggested in my first reply (http://www.html5gamedevs.com/topic/4005-rough-terrain-smooth/?p=26450)

if (position.y >= distance) {    position.y -= fullHeight / 4 * (10/9 - distance / (radius * 0.9)); // 0.5 * (fullHeight / 2) * (1.0 - (distance - radius * 0.1) / (radius * 0.9))}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...