TestPace X [ Developing]

Started by Yue, January 17, 2018, 01:17:05

Previous topic - Next topic

Yue



Okay, I already have the oxygen system related to the player's life bar.  Oxygen has a stable average when the oxygen condenser is in perfect operation, if the player runs consumes more oxygen, if the condenser is defective the oxygen runs out much faster than usual, it means that something is wrong.  When oxygen reaches zero, the oxygen indicator changes from green to red and the player's life bar starts to be affected constantly until it reaches zero and dies

Translated with www.DeepL.com/Translator

Yue


And that left the main loop of the program, the most efficient way to avoid performance losses.


Code (blitzbasic) Select


Repeat

For sss.rock = Each rock


If EntityDistance(vehiculo\ruedas[0]\ente,  sss\entity ) < 2 Or EntityDistance(vehiculo\ruedas[1]\ente,  sss\entity ) < 2 Or EntityDistance(vehiculo\ruedas[2]\ente,  sss\entity ) < 2 Or EntityDistance(vehiculo\ruedas[3]\ente,  sss\entity ) < 2 Or EntityDistance(jugador\jugador\ente,  sss\entity ) < 5
ScaleEntity ( piedraPx\ente,  sss\scale,  sss\scale,  sss\scale)
RotateEntity( piedraPx\ente, sss\pitch,sss\yaw,sss\roll)
phBodySetPos( pxPiedra, EntityX(sss\entity),EntityY(sss\entity),EntityZ(sss\entity) ) 
   
End If



Next


; DENSITY=Normalize(Perlin3D(EntityX(jugador\jugador\ente),0,EntityZ(jugador\jugador\ente),8,1,0,3),0,1,0,100)
;
; If DENSITY>500 Then DENSITY=500 Else If DENSITY<5 Then DENSITY=500



Repeat  :  elapsed = MilliSecs() - time  :  Until elapsed
ticks = elapsed / period
tween# = Float(elapsed Mod period) / Float(period)
For k=1 To ticks
time = time + period
If k = ticks Then CaptureWorld

WorldStep(0.00005)



UpdateWorld


UpdateParticulasRuedas(vehiculo.TVehiculo )
UpdateParticles()
MontarVehiclo(vehiculo.TVehiculo, jugador.TJugador)
UpdateJugador( jugador.TJugador, vehiculo\chassis\ente, camara.TCamara )
UpdateWheels( vehiculo.TVehiculo )
UpdateRocas()



RenderWorld(teewn)
RenderPostprocess FE_Blur + FE_Glow   ;+ FE_Contrast

StartDraw()

InfoDebug(fuenteBlitz.TFuente, vehiculo.TVehiculo )
DrawHud(jugador.TJugador)

EndDraw()


UpdateShadows ( vehiculo\chassis\ente)
UpdateDist_Sombras( sombra1, sombra2 )


Next





Flip(0)


If KeyHit(KEY_ESC) Then

Exit

End If


If KeyDown(KEY_P) Then
GuardarImagen()

End If


Forever

LiberarMemoria()

Yue

Today I have made a great advance, to improve the performance, since when I was recording a video frame rate was affected drastically, the video I am currently uploading remains stable at 63 / 64 frames per second.  I thought it was badicam that inferred in this, but apparently I had a bad coding.  So just wait a little longer for the video to be on Youtube.


Yue

And before bedtime, the simple pitcher of the game. Where I hope to put screen resolution options, shadow quality, rock density on the ground, activate the brightness effect and other geese.


RemiD

#140
@Yue>>to "improve performance", you should rather do a distance check between the center of your vehicle and each rock, not between each wheel / vehiclepart and each rock...


Also, maybe add less rocks but bigger rocks. They are barely visible...

Yue

The issue of rocks and tires is that I only have one collider per rock, if I put the center of the vehicle two rocks or more will only have collision.

With a density of 10 I have 45 rocks visible in a range of 360 from a distance of 250 units, with a density of 100 I have 700 rocks. I'll make more rocks big.



Derron

There is no need to do "collision checks" to find out if you want to display something or not.

Center of your car is Vector 1 (XYZ)
Center of a rock is Vector 2 (XYZ)

Then you calculate the distance between those two vectors: if the distance is bigger than X, then do not render it.

Distance of XYZ:
with the help of pythagoras (a² + b² = c²) you can calculate distances of 2 points on a flat surface ("2D"). With the result of this, you can add the 3rd dimension (z) and do the same again.



local distanceX:Float = abs(x - otherVec.x)
local distanceY:Float = abs(y - otherVec.y)
local distanceZ:Float = abs(z - otherVec.z)

'a² + b² = c²... pythagoras
local distanceXY:Float = Sqr(distanceX * distanceX + distanceY * distanceY)

'save computation time if no z-difference was done
If distanceZ <> 0
'this time a² is the result of the first 2D triangle
Return Sqr(distanceXY * distanceXY + distanceZ * distanceZ)
Else
Return distanceXY
Endif



@ collisions
Have a big bounding box for your car - so it contains all elements of the car. Only do detailled collision checks (left front wheel, right front wheel, ...) if the bounding box hit the bounding box of other elements.
Also: do not check for collisions with items far away from you.

If an element is sized 1x1x1 and is away 10 units, then it cannot hit you.



@ rocks
As said, use some bigger rocks as I assume it is not the render speed which limits your frame rate but the amount of objects (and possibly a not really "optimized" way of doing the stuff).


bye
Ron

Yue

@Derron, Always something new to learn.   :o  :)

Yue



Well, I have optimized the issue of rocks, with a density of 100%, I have on screen rendered 160 rocks, with a density of 10% only 13 rocks. Now the problem is with the collisions, the corgo hull assigned to each rock near the car, it is impossible to scale its size to match that of the visible rock, so it only had rocks of a single size. I'm trying to think of something.

Derron

Scale of rock = scale of hull.
Also: you scale a rock once ...on level creation. So you could create the hull there.

But again: do not check for collisions with objects way too far away.

Bye
Ron

Naughty Alien

..i would drop SQR from distance check as it is as accurate as it can be without it, but speed will increase as this check is looping a lot i guess..

Yue

This undoubtedly leads me to two options, rocks of the same size, or simply without rocks. 

The idea is that the rocks update their position, their rotation around the car, regardless of where the fence exists 160 rocks are updated, giving the impression that the whole terrain is full of rocks.  I have to come up with a different solution to this problem.


Yue

#148
The solution is rocks of the same size, but the simple trick is that the position of the ground that rock can be more exit, or more sunk on the ground, so it seems that the rock is a little smaller.




Yue

Okay, rocks with the dirty trick.
rocks joined in the ground and other exits