objects distorting at great distances apart

The other day someone asked about making a solar system in BGE…I thought I had a solution but apparently I did not.

So heres the problem…when you have objects at great distances apart or their sizes are greatly different you begin to have distortion in the models. for Example

I places a sphere at (0,0,0). with a diameter of 10,000 bu’s(km)
I places another sphere at (829553400,0,0) representing jupiters distance from the sun. But kept the sphere at 10,000 diameter. Ive adjusted view clippings and those types of things.

The problem is when I set items very very far apart like this I get distortion in the models like this.

Even if I divide all models dimensions and distances by 1000(scale them down) I get the same distortion. Its like blender cant handle doing something with the great distances between them. Scaled or otherwise.

Is there a setting or solution to stop the distortion, Or is this just to much for blender to handle.

Two possible causes:

That is normal and relies to number precision.

The precision (of float numbers) decreases as larger the distance to zero.

Near zero you can handle tiny fractions of a number.

The storage for numbers is limited and typically constant. Imagine you have a form with 5 digits. You can have ten possible characters to describe digits [0…9]. This means you have 1010101010 = 10^5 = 10000 possible combinations which can represent unique numbers. You can’t have more numbers.

You as human would say: I can express 10000 numbers.

But it does not say what numbers that are. It just limits on 10000 pieces.

This can be fixed stepsize:

0,1,2, … 9999, 10000

with different begin:
-4999, -4998, … 0, … 4999, 5000
-5000, -4999, -4998 … 0, … 4999

and other step sizes:
0.0, 0.1, … 999.0, 1000.0

it depends what you want to achieve. The limit of 10000 possible numbers is always there.

I hope you see to get small numbers you need to decrease the step size. Why not move the decimal dependent on the dimension of the number? E.g. a single cm is typically not so important when you deal with km. So we can “round” it. This increases the range of values (into the km range) but still allows us to express small numbers (at mm range). The overall limit is still there. So we by it that numbers around 0 are more precise than numbers near the outer limits.

the range can be like that:
-4900, -4801, … -0.0004, -0.0001, 0.0000, 0.0001, 0.0004, … 4801, 4900, 5000

The BGE uses a similar system (with more numbers and binary representation).

When you model objects far away from scene origin, you will discover precision issues,
So I strongly advice to keep you camera near the scene origin (raw estimate: the origin should be somewhere the camera’s frustum length (if it is 100BU be within 100 BU)).

Btw. Typical implementations of Z-Buffer have increased precision near the camera. If you think about it it makes sense as little details are more visible when you are close to them. This also means z-Buffer problems (see Z-Buffer fighting) are earlier visible near the far-plane.

Only worry about that when you discover problems.

When you get problems, you could move all objects of the scene that the camera is near the origin again.

A similar thing to number precision is Z-Buffer precision. The Z-Buffer (see wikipedia) is used to determine if a pixel should be drawn or not. It is a very fast method to see if another pixel is in front of the current one or not.

This is bought by a lot of memory as you need to store the distance for each single pixel on the screen. As less memory spend as less precise the distance check is. If pixels of two faces are very close to each other the Render can’t decide which covers the other. This can result in an incorrect and visible calculation.

To increase the precision of your z-Buffer you need to decrease the distance between near- and far-plane of the camera. Yes, it means you can’t see further than the far-plane.

Find a balance between small details and the view range.

I hope this helps a bit.

As monster said you need a close far clipping value in order to keep z buffer precision. That means you can’t see a distant planet and a close planet at the same time without distortion. You might consider making distant planets invisible anyway or using sprites + LOD. Or just place a sprite relative to the player and the distant planet’s position. Traveling between planets would take months anyway even at hundreds of thousands of kph, which you’ll find is another problem as it messes with collision when you move fast like that.

for CCD with high speed moving objects, you just need to cast a ray, from the leading edge points, to where the object will be the next frame,

I tend to use endpoint = (own.worldPosition + (own.worldLinearVelocity*multiplier)) but there is probably something more accurate.

one issue is it wont detect two moving objects crossing on a point at great speed, (unless they happen to be at the point at that frame)