Thread View: comp.lang.c
14 messages
14 total messages
Started by fir
Mon, 23 Nov 2026 20:00
[pic] avoidance problem
Author: fir
Date: Mon, 23 Nov 2026 20:00
Date: Mon, 23 Nov 2026 20:00
16 lines
2003 bytes
2003 bytes
imagine you got a flyin ships in space (which may be treated as spheres) they got direction and forvard velocity, they may turn yaw/pitch also slow down or accelerate... the yaw pitch slowdown/acceleraty is by applying forces (yaw_force, pitch_force.. and so on, this force is from 0.0 to 1.0 which is max, usualy max is applied and this force gives increases some taw/pitch velocity but there is also damping) the problem is i need to vrite a good routine that would make good result in avoiding the input is position, radius, direction, forward_velocity for both participants (i mean for each ship i run it in the loop for any other so it make pairs) what ai gives me not quite work and this is exampla how working with ai look like, i need myself somewhat rationalize it to find good answer
Re: [pic] avoidance problem
Author: fir
Date: Mon, 23 Nov 2026 22:29
Date: Mon, 23 Nov 2026 22:29
104 lines
4882 bytes
4882 bytes
fir pisze:
> imagine you got a flyin ships in space (which may be treated as spheres)
> they got direction and forvard velocity, they may turn yaw/pitch also
> slow down or accelerate... the yaw pitch slowdown/acceleraty is by
> applying forces (yaw_force, pitch_force.. and so on, this force is from
> 0.0 to 1.0 which is max, usualy max is applied and this force gives
> increases some taw/pitch velocity but there is also damping)
>
> the problem is i need to vrite a good routine that would make good
> result in avoiding
>
> the input is position, radius, direction, forward_velocity for both
> participants (i mean for each ship i run it in the loop for any other so
> it make pairs)
>
> what ai gives me not quite work and this is exampla how working with ai
> look like, i need myself somewhat rationalize it to find good answer
some idea come to me and ai - not to think in geometry (in which im not
good) but just count a next point, count a next point if i would turn
right, left , count a next point if i turn down, up , count next point
if i speed up, down -- and chose the point which is most far to
collision..thats great local simplicity though all those countings are
sorta heavy
void AvoidSphere(int i, float i_radius, float3 object_pos,float3
object_velocity,float object_radius)
{
float3 object_next=add(object_pos,object_velocity);
float avoid_radius=object_radius + i_radius + AVOID_DISTANCE;
float3 to_object=sub(object_pos,bag[i].p.pos);
float distance0=length(to_object);
if(distance0>=avoid_radius) return;
bag[i].is_avoiding+=1;
/* Punkt, w którym statek znajdzie się bez żadnej dodatkowej siły. */
float3 p0=PredictNextFrameObjectPosition(i,0,0,0,0,0,0);
float best_distance=distance(p0,object_next);
float best_yaw=0;
float best_pitch=0;
float best_forward=0;
/* Lewo / prawo. */
float3 p;
float d;
p=PredictNextFrameObjectPosition(i, 1,0,0,0,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
best_forward=0; }
p=PredictNextFrameObjectPosition(i,-1,0,0,0,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
best_forward=0; }
p=PredictNextFrameObjectPosition(i,0, 1,0,0,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
best_forward=0; }
p=PredictNextFrameObjectPosition(i,0,-1,0,0,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
best_forward=0; }
p=PredictNextFrameObjectPosition(i, 1,0,0,1,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
best_forward=1; }
p=PredictNextFrameObjectPosition(i,-1,0,0,1,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
best_forward=1; }
p=PredictNextFrameObjectPosition(i,0, 1,0,1,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
best_forward=1; }
p=PredictNextFrameObjectPosition(i,0,-1,0,1,0,0);
d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
best_forward=1; }
/* Wybieramy najlepszy ruch. */
bag[i].yaw_force=best_yaw;
bag[i].pitch_force=best_pitch;
bag[i].forward_force=best_forward;
}
also there is case when ships could collide with more things they avoid
one and just run stright into another and explode ;c
i alos not sure if it behaves well in 1-1 collisions such things are
quite hard to visually debug
Re: [pic] avoidance problem
Author: fir
Date: Mon, 23 Nov 2026 23:23
Date: Mon, 23 Nov 2026 23:23
188 lines
7132 bytes
7132 bytes
fir pisze:
> fir pisze:
>> imagine you got a flyin ships in space (which may be treated as spheres)
>> they got direction and forvard velocity, they may turn yaw/pitch also
>> slow down or accelerate... the yaw pitch slowdown/acceleraty is by
>> applying forces (yaw_force, pitch_force.. and so on, this force is
>> from 0.0 to 1.0 which is max, usualy max is applied and this force
>> gives increases some taw/pitch velocity but there is also damping)
>>
>> the problem is i need to vrite a good routine that would make good
>> result in avoiding
>>
>> the input is position, radius, direction, forward_velocity for both
>> participants (i mean for each ship i run it in the loop for any other
>> so it make pairs)
>>
>> what ai gives me not quite work and this is exampla how working with
>> ai look like, i need myself somewhat rationalize it to find good answer
>
>
>
> some idea come to me and ai - not to think in geometry (in which im not
> good) but just count a next point, count a next point if i would turn
> right, left , count a next point if i turn down, up , count next point
> if i speed up, down -- and chose the point which is most far to
> collision..thats great local simplicity though all those countings are
> sorta heavy
>
>
>
>
> void AvoidSphere(int i, float i_radius, float3 object_pos,float3
> object_velocity,float object_radius)
> {
> float3 object_next=add(object_pos,object_velocity);
>
> float avoid_radius=object_radius + i_radius + AVOID_DISTANCE;
>
> float3 to_object=sub(object_pos,bag[i].p.pos);
> float distance0=length(to_object);
>
> if(distance0>=avoid_radius) return;
>
> bag[i].is_avoiding+=1;
>
> /* Punkt, w którym statek znajdzie się bez żadnej dodatkowej siły. */
> float3 p0=PredictNextFrameObjectPosition(i,0,0,0,0,0,0);
> float best_distance=distance(p0,object_next);
>
> float best_yaw=0;
> float best_pitch=0;
> float best_forward=0;
>
> /* Lewo / prawo. */
> float3 p;
> float d;
>
> p=PredictNextFrameObjectPosition(i, 1,0,0,0,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
> best_forward=0; }
> p=PredictNextFrameObjectPosition(i,-1,0,0,0,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
> best_forward=0; }
> p=PredictNextFrameObjectPosition(i,0, 1,0,0,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
> best_forward=0; }
> p=PredictNextFrameObjectPosition(i,0,-1,0,0,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
> best_forward=0; }
>
> p=PredictNextFrameObjectPosition(i, 1,0,0,1,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
> best_forward=1; }
> p=PredictNextFrameObjectPosition(i,-1,0,0,1,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
> best_forward=1; }
> p=PredictNextFrameObjectPosition(i,0, 1,0,1,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
> best_forward=1; }
> p=PredictNextFrameObjectPosition(i,0,-1,0,1,0,0);
> d=distance(p,object_next);
> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
> best_forward=1; }
>
>
> /* Wybieramy najlepszy ruch. */
> bag[i].yaw_force=best_yaw;
> bag[i].pitch_force=best_pitch;
> bag[i].forward_force=best_forward;
> }
>
>
>
> also there is case when ships could collide with more things they avoid
> one and just run stright into another and explode ;c
>
> i alos not sure if it behaves well in 1-1 collisions such things are
> quite hard to visually debug
some addition to avoid the closest resolved part of problems
int FindClosestColiding(int i,float* dist,int* n_colliding)
{
float ship_collision_radius=ShipRadius(i);
float closest_distance=1000000000.0f;
int closest=-1;
*n_colliding=0;
for(int j=0;j<bag_max;j++)
{
if(!bag[j].enabled) continue;
if(j==i) continue;
float object_radius;
if(bag[j].type=='ship' || bag[j].type=='play')
object_radius=ShipRadius(j);
else if(bag[j].type=='aste')
object_radius=AsteroidRadius(j);
else
continue;
float d=distance(bag[i].p.pos, bag[j].p.pos);
float
collision_distance=ship_collision_radius+object_radius+AVOID_DISTANCE;
if(d<collision_distance)
{
(*n_colliding)++;
if(d<closest_distance)
{
closest_distance=d;
closest=j;
}
}
}
*dist=closest_distance;
return closest;
}
void AvoidCollisions(int i)
{
bag[i].is_avoiding=0;
float distance;
int n_colliding;
int j=FindClosestColiding(i,&distance,&n_colliding);
if(j<0) return;
bag[i].is_avoiding=n_colliding;
float ship_collision_radius=ShipRadius(i);
if(bag[j].type=='ship' || bag[j].type=='play')
AvoidSphere(i,ship_collision_radius,bag[j].p.pos,GetShipWholeVelocity(j),ShipRadius(j));
else if(bag[j].type=='aste')
AvoidSphere(i,ship_collision_radius,bag[j].p.pos,f3(0,0,0),AsteroidRadius(j));
}
but how to deduce if it is right - red circle marks if the avoiding
routine is in work - finally the ship anyway colide
what is seen on video (i got heavy drop of fps onvideo sometimes it
ahppen probably depent on hat i run in parralel and i forgot to close
some apps)
https://www.youtube.com/watch?v=DWJI_BO_IdM
Re: [pic] avoidance problem
Author: Ross Finlayson
Date: Mon, 23 Nov 2026 23:57
Date: Mon, 23 Nov 2026 23:57
212 lines
8461 bytes
8461 bytes
On 11/23/2026 03:23 PM, fir wrote:
> fir pisze:
>> fir pisze:
>>> imagine you got a flyin ships in space (which may be treated as spheres)
>>> they got direction and forvard velocity, they may turn yaw/pitch also
>>> slow down or accelerate... the yaw pitch slowdown/acceleraty is by
>>> applying forces (yaw_force, pitch_force.. and so on, this force is
>>> from 0.0 to 1.0 which is max, usualy max is applied and this force
>>> gives increases some taw/pitch velocity but there is also damping)
>>>
>>> the problem is i need to vrite a good routine that would make good
>>> result in avoiding
>>>
>>> the input is position, radius, direction, forward_velocity for both
>>> participants (i mean for each ship i run it in the loop for any other
>>> so it make pairs)
>>>
>>> what ai gives me not quite work and this is exampla how working with
>>> ai look like, i need myself somewhat rationalize it to find good answer
>>
>>
>>
>> some idea come to me and ai - not to think in geometry (in which im
>> not good) but just count a next point, count a next point if i would
>> turn right, left , count a next point if i turn down, up , count next
>> point if i speed up, down -- and chose the point which is most far to
>> collision..thats great local simplicity though all those countings are
>> sorta heavy
>>
>>
>>
>>
>> void AvoidSphere(int i, float i_radius, float3 object_pos,float3
>> object_velocity,float object_radius)
>> {
>> float3 object_next=add(object_pos,object_velocity);
>>
>> float avoid_radius=object_radius + i_radius + AVOID_DISTANCE;
>>
>> float3 to_object=sub(object_pos,bag[i].p.pos);
>> float distance0=length(to_object);
>>
>> if(distance0>=avoid_radius) return;
>>
>> bag[i].is_avoiding+=1;
>>
>> /* Punkt, w którym statek znajdzie się bez żadnej dodatkowej
>> siły. */
>> float3 p0=PredictNextFrameObjectPosition(i,0,0,0,0,0,0);
>> float best_distance=distance(p0,object_next);
>>
>> float best_yaw=0;
>> float best_pitch=0;
>> float best_forward=0;
>>
>> /* Lewo / prawo. */
>> float3 p;
>> float d;
>>
>> p=PredictNextFrameObjectPosition(i, 1,0,0,0,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
>> best_forward=0; }
>> p=PredictNextFrameObjectPosition(i,-1,0,0,0,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
>> best_forward=0; }
>> p=PredictNextFrameObjectPosition(i,0, 1,0,0,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
>> best_forward=0; }
>> p=PredictNextFrameObjectPosition(i,0,-1,0,0,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
>> best_forward=0; }
>>
>> p=PredictNextFrameObjectPosition(i, 1,0,0,1,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
>> best_forward=1; }
>> p=PredictNextFrameObjectPosition(i,-1,0,0,1,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
>> best_forward=1; }
>> p=PredictNextFrameObjectPosition(i,0, 1,0,1,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
>> best_forward=1; }
>> p=PredictNextFrameObjectPosition(i,0,-1,0,1,0,0);
>> d=distance(p,object_next);
>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
>> best_forward=1; }
>>
>>
>> /* Wybieramy najlepszy ruch. */
>> bag[i].yaw_force=best_yaw;
>> bag[i].pitch_force=best_pitch;
>> bag[i].forward_force=best_forward;
>> }
>>
>>
>>
>> also there is case when ships could collide with more things they
>> avoid one and just run stright into another and explode ;c
>>
>> i alos not sure if it behaves well in 1-1 collisions such things are
>> quite hard to visually debug
>
> some addition to avoid the closest resolved part of problems
>
>
>
> int FindClosestColiding(int i,float* dist,int* n_colliding)
> {
> float ship_collision_radius=ShipRadius(i);
> float closest_distance=1000000000.0f;
> int closest=-1;
>
> *n_colliding=0;
>
> for(int j=0;j<bag_max;j++)
> {
> if(!bag[j].enabled) continue;
> if(j==i) continue;
>
> float object_radius;
>
> if(bag[j].type=='ship' || bag[j].type=='play')
> object_radius=ShipRadius(j);
> else if(bag[j].type=='aste')
> object_radius=AsteroidRadius(j);
> else
> continue;
>
> float d=distance(bag[i].p.pos, bag[j].p.pos);
> float
> collision_distance=ship_collision_radius+object_radius+AVOID_DISTANCE;
>
> if(d<collision_distance)
> {
> (*n_colliding)++;
>
> if(d<closest_distance)
> {
> closest_distance=d;
> closest=j;
> }
> }
> }
>
> *dist=closest_distance;
>
> return closest;
> }
>
>
> void AvoidCollisions(int i)
> {
> bag[i].is_avoiding=0;
>
> float distance;
> int n_colliding;
>
> int j=FindClosestColiding(i,&distance,&n_colliding);
>
> if(j<0) return;
>
> bag[i].is_avoiding=n_colliding;
>
> float ship_collision_radius=ShipRadius(i);
>
> if(bag[j].type=='ship' || bag[j].type=='play')
> AvoidSphere(i,ship_collision_radius,bag[j].p.pos,GetShipWholeVelocity(j),ShipRadius(j));
>
> else if(bag[j].type=='aste')
> AvoidSphere(i,ship_collision_radius,bag[j].p.pos,f3(0,0,0),AsteroidRadius(j));
>
> }
>
>
>
> but how to deduce if it is right - red circle marks if the avoiding
> routine is in work - finally the ship anyway colide
>
> what is seen on video (i got heavy drop of fps onvideo sometimes it
> ahppen probably depent on hat i run in parralel and i forgot to close
> some apps)
>
>
> https://www.youtube.com/watch?v=DWJI_BO_IdM
"Octrees" after "quadtrees" were already in the computer science
literature circa 1990-ish (when Doom came out).
Pyramidal/hierarchical vis-a-vis lattice accounts are pretty usual.
Collision detection is a pretty hard problem, usually after bounding-boxes.
Physics the mechanics' account still can't exactly explain "static
torque", or why that since Galileo's laws say nothing about spinning
bodies, there's room in the theory, then, that Magnus and Coriolis
effects can't be added up to explain away ballistics, there's room
in the data, for the whole "space-contraction-linear and
space-contraction-rotational and inertial-systems where momentum is
not conserved", about that nothing's ever exactly "equal & opposite"
(though theories like as after Galileo's and Newton's are plenty
good, or, "up to first, second, third orders").
Re: [pic] avoidance problem
Author: fir
Date: Tue, 24 Nov 2026 00:58
Date: Tue, 24 Nov 2026 00:58
234 lines
9866 bytes
9866 bytes
Ross Finlayson pisze:
> On 11/23/2026 03:23 PM, fir wrote:
>> fir pisze:
>>> fir pisze:
>>>> imagine you got a flyin ships in space (which may be treated as
>>>> spheres)
>>>> they got direction and forvard velocity, they may turn yaw/pitch also
>>>> slow down or accelerate... the yaw pitch slowdown/acceleraty is by
>>>> applying forces (yaw_force, pitch_force.. and so on, this force is
>>>> from 0.0 to 1.0 which is max, usualy max is applied and this force
>>>> gives increases some taw/pitch velocity but there is also damping)
>>>>
>>>> the problem is i need to vrite a good routine that would make good
>>>> result in avoiding
>>>>
>>>> the input is position, radius, direction, forward_velocity for both
>>>> participants (i mean for each ship i run it in the loop for any other
>>>> so it make pairs)
>>>>
>>>> what ai gives me not quite work and this is exampla how working with
>>>> ai look like, i need myself somewhat rationalize it to find good answer
>>>
>>>
>>>
>>> some idea come to me and ai - not to think in geometry (in which im
>>> not good) but just count a next point, count a next point if i would
>>> turn right, left , count a next point if i turn down, up , count next
>>> point if i speed up, down -- and chose the point which is most far to
>>> collision..thats great local simplicity though all those countings are
>>> sorta heavy
>>>
>>>
>>>
>>>
>>> void AvoidSphere(int i, float i_radius, float3 object_pos,float3
>>> object_velocity,float object_radius)
>>> {
>>> float3 object_next=add(object_pos,object_velocity);
>>>
>>> float avoid_radius=object_radius + i_radius + AVOID_DISTANCE;
>>>
>>> float3 to_object=sub(object_pos,bag[i].p.pos);
>>> float distance0=length(to_object);
>>>
>>> if(distance0>=avoid_radius) return;
>>>
>>> bag[i].is_avoiding+=1;
>>>
>>> /* Punkt, w którym statek znajdzie się bez żadnej dodatkowej
>>> siły. */
>>> float3 p0=PredictNextFrameObjectPosition(i,0,0,0,0,0,0);
>>> float best_distance=distance(p0,object_next);
>>>
>>> float best_yaw=0;
>>> float best_pitch=0;
>>> float best_forward=0;
>>>
>>> /* Lewo / prawo. */
>>> float3 p;
>>> float d;
>>>
>>> p=PredictNextFrameObjectPosition(i, 1,0,0,0,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
>>> best_forward=0; }
>>> p=PredictNextFrameObjectPosition(i,-1,0,0,0,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
>>> best_forward=0; }
>>> p=PredictNextFrameObjectPosition(i,0, 1,0,0,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
>>> best_forward=0; }
>>> p=PredictNextFrameObjectPosition(i,0,-1,0,0,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
>>> best_forward=0; }
>>>
>>> p=PredictNextFrameObjectPosition(i, 1,0,0,1,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=1; best_pitch=0;
>>> best_forward=1; }
>>> p=PredictNextFrameObjectPosition(i,-1,0,0,1,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=-1; best_pitch=0;
>>> best_forward=1; }
>>> p=PredictNextFrameObjectPosition(i,0, 1,0,1,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=1;
>>> best_forward=1; }
>>> p=PredictNextFrameObjectPosition(i,0,-1,0,1,0,0);
>>> d=distance(p,object_next);
>>> if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-1;
>>> best_forward=1; }
>>>
>>>
>>> /* Wybieramy najlepszy ruch. */
>>> bag[i].yaw_force=best_yaw;
>>> bag[i].pitch_force=best_pitch;
>>> bag[i].forward_force=best_forward;
>>> }
>>>
>>>
>>>
>>> also there is case when ships could collide with more things they
>>> avoid one and just run stright into another and explode ;c
>>>
>>> i alos not sure if it behaves well in 1-1 collisions such things are
>>> quite hard to visually debug
>>
>> some addition to avoid the closest resolved part of problems
>>
>>
>>
>> int FindClosestColiding(int i,float* dist,int* n_colliding)
>> {
>> float ship_collision_radius=ShipRadius(i);
>> float closest_distance=1000000000.0f;
>> int closest=-1;
>>
>> *n_colliding=0;
>>
>> for(int j=0;j<bag_max;j++)
>> {
>> if(!bag[j].enabled) continue;
>> if(j==i) continue;
>>
>> float object_radius;
>>
>> if(bag[j].type=='ship' || bag[j].type=='play')
>> object_radius=ShipRadius(j);
>> else if(bag[j].type=='aste')
>> object_radius=AsteroidRadius(j);
>> else
>> continue;
>>
>> float d=distance(bag[i].p.pos, bag[j].p.pos);
>> float
>> collision_distance=ship_collision_radius+object_radius+AVOID_DISTANCE;
>>
>> if(d<collision_distance)
>> {
>> (*n_colliding)++;
>>
>> if(d<closest_distance)
>> {
>> closest_distance=d;
>> closest=j;
>> }
>> }
>> }
>>
>> *dist=closest_distance;
>>
>> return closest;
>> }
>>
>>
>> void AvoidCollisions(int i)
>> {
>> bag[i].is_avoiding=0;
>>
>> float distance;
>> int n_colliding;
>>
>> int j=FindClosestColiding(i,&distance,&n_colliding);
>>
>> if(j<0) return;
>>
>> bag[i].is_avoiding=n_colliding;
>>
>> float ship_collision_radius=ShipRadius(i);
>>
>> if(bag[j].type=='ship' || bag[j].type=='play')
>> AvoidSphere(i,ship_collision_radius,bag[j].p.pos,GetShipWholeVelocity(j),ShipRadius(j));
>>
>>
>> else if(bag[j].type=='aste')
>> AvoidSphere(i,ship_collision_radius,bag[j].p.pos,f3(0,0,0),AsteroidRadius(j));
>>
>>
>> }
>>
>>
>>
>> but how to deduce if it is right - red circle marks if the avoiding
>> routine is in work - finally the ship anyway colide
>>
>> what is seen on video (i got heavy drop of fps onvideo sometimes it
>> ahppen probably depent on hat i run in parralel and i forgot to close
>> some apps)
>>
>>
>> https://www.youtube.com/watch?v=DWJI_BO_IdM
>
> "Octrees" after "quadtrees" were already in the computer science
> literature circa 1990-ish (when Doom came out).
>
> Pyramidal/hierarchical vis-a-vis lattice accounts are pretty usual.
>
> Collision detection is a pretty hard problem, usually after bounding-boxes.
>
>
doesnt seem tpo hard (in simple version, optimisation for big amount of
coliding bodies may worry me) but there is a need to see it in simple way
its also unusually hard to debug by eyes..i got something but is that
good o r bad, i dont know..it seems to avoid some collisions but with
some will crash (maybe no wonder as it has limits to change speed but
maybe its bad becouse it could avoid in limits, hard to say...
yet sometimes those ships look like flyin in small radius circles which
is unwelcome, tooo
so i wouldnt say its to hard It's not particularly difficult, but it
does require some know-how like when hammering nails etc
its in some way interesting though - so i post the question in case
someone is boring
>
> Physics the mechanics' account still can't exactly explain "static
> torque", or why that since Galileo's laws say nothing about spinning
> bodies, there's room in the theory, then, that Magnus and Coriolis
> effects can't be added up to explain away ballistics, there's room
> in the data, for the whole "space-contraction-linear and
> space-contraction-rotational and inertial-systems where momentum is
> not conserved", about that nothing's ever exactly "equal & opposite"
> (though theories like as after Galileo's and Newton's are plenty
> good, or, "up to first, second, third orders").
>
>
>
Re: [pic] avoidance problem
Author: fir
Date: Tue, 24 Nov 2026 16:28
Date: Tue, 24 Nov 2026 16:28
146 lines
4742 bytes
4742 bytes
i took presently such:
float3 PredictPoint(int i,float Forw,float Yaw,float Pitch)
{
float3 dir=bag[i].p.dir;
float3 right=bag[i].p.right;
float3 down=bag[i].p.down;
float2 cy=fcosin(Yaw);
float2 cp=fcosin(Pitch);
float3 d=add(mul(dir,cy.x),mul(right,cy.y));
d=add(mul(d,cp.x),mul(down,cp.y));
normalize(&d);
return add(bag[i].p.pos, mul(d, Forw));
}
void AvoidSphere(int i, int whom)
{
float i_radius = bag[i].radius;
float3 object_pos = bag[whom].p.pos;
float3 object_velocity= ObjectVelocity(whom);
float object_radius = bag[whom].radius;
float3 object_next=add(object_pos, object_velocity);
float avoid_radius=object_radius + i_radius + AVOID_DISTANCE;
float3 to_object=sub(object_pos,bag[i].p.pos);
float distance0=length(to_object);
if(distance0>=avoid_radius) return;
float best_distance=0;
float best_yaw=0;
float best_pitch=0;
float best_forward=0;
float3 p; float d,d1,d2;
float F = 20*4; //check distance
float A = .5; //chack angles
float V = .3; //apply turn force
p=PredictPoint(i, F,0, 0); d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=0;
best_forward=1; }
p=PredictPoint(i, F, A, 0); d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=V; best_pitch=0;
best_forward=1; }
p=PredictPoint(i, F,-A, 0); d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=-V; best_pitch=0;
best_forward=1; }
p=PredictPoint(i, F, 0, A); d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=V;
best_forward=1; }
p=PredictPoint(i, F, 0, -A); d=distance(p,object_next);
if(d>best_distance) { best_distance=d; best_yaw=0; best_pitch=-V;
best_forward=1; }
/* Wybieramy najlepszy ruch. */
bag[i].yaw_force=best_yaw;
bag[i].pitch_force=best_pitch;
bag[i].forward_force=best_forward;
}
inline int MayCollide(int w)
{
unsigned wt = bag[w].type;
if(wt=='ship') return 1;
if(wt=='play') return 1;
if(wt=='aste') return 1;
return 0;
}
int FindClosestColiding(int i,float* dist,int* n_colliding)
{
float ship_collision_radius=ShipRadius(i);
float closest_distance=1000000000.0f;
int closest=-1;
*n_colliding=0;
for(int j=0;j<bag_max;j++)
{
if(!bag[j].enabled) continue;
if(j==i) continue;
float object_radius = bag[j].radius;
if(MayCollide(j)) {} else continue;
float d=distance(bag[i].p.pos, bag[j].p.pos);
float
collision_distance=ship_collision_radius+object_radius+AVOID_DISTANCE;
if(d<collision_distance)
{
(*n_colliding)++;
if(d<closest_distance)
{
closest_distance=d;
closest=j;
}
}
}
*dist=closest_distance;
return closest;
}
void AvoidCollisions(int i)
{
bag[i].is_avoiding=0;
if(!bag[i].enabled) return;
float distance;
int n_colliding=0;
int w=FindClosestColiding(i,&distance,&bag[i].is_avoiding); if(w<0) return;
if(MayCollide(w))
AvoidSphere(i,w);
}
it visually behaves roughly ok buts far from optimal i guess..as this
was chosen by some experimentations
(where the goal was to avoid those circles when ships avoid something
and start to round in smal circles, and avoid collisions per se..
if i got more time i should find something better)
Re: [pic] avoidance problem
Author: fir
Date: Wed, 25 Nov 2026 19:43
Date: Wed, 25 Nov 2026 19:43
22 lines
2154 bytes
2154 bytes
not ebtw how great ai is https://www.youtube.com/watch?v=Bi7XPFZBwTE tired on stessing on doing those pilot combat routines (which is stressful) i thinked today - maybe i should jump to another world, thus i need round portals to fly thru - and i made my first inter world jump (jump i coded but ai done a dettection of moment of it when passing portal plane which if no it would take longer) see the video of one of my first interdimensional jumps (ofc i jumped in hiperspace in old elite but those jumps here are better) those worlds i jump among are quite separate but out of simplicity put same things in same positions but later i will change it..so teh gates to new worlds become opan and its always good..iznt it?) fir
Re: [pic] avoidance problem
Author: fir
Date: Thu, 26 Nov 2026 00:52
Date: Thu, 26 Nov 2026 00:52
51 lines
3365 bytes
3365 bytes
fir pisze: > not ebtw how great ai is > > https://www.youtube.com/watch?v=Bi7XPFZBwTE > > tired on stessing on doing those pilot combat routines > (which is stressful) i thinked today - maybe i should jump > to another world, thus i need round portals to fly thru - > > and i made my first inter world jump > > (jump i coded but ai done a dettection of moment of it when passing portal > plane which if no it would take longer) > > see the video of one of my first interdimensional jumps > (ofc i jumped in hiperspace in old elite but those jumps here are better) > > those worlds i jump among are quite separate but out of simplicity put > same things in same positions but later i will change it..so teh gates > to new worlds become opan and its always good..iznt it?) > > fir > maybe some interesting curiosities as to this inter traweling to other worlds first version was the part of teh world data was destroyed when leaving the world and then reinitialized as like at game start (i did it becouse it was faster) - curiosity is hat that those big asteroids positions was based on rand() and rand was no reinitialised so there was a chance that you go back thru portal but now asteroid is just after the portal and you smash hard on it (did that twice or 3-4 times) now repaired and just data of given world is preserved(just not destroyed) but it makes another curious behaviour when you travel first time you get located at 0,0,0 point but when you back you will jump to exact time and position you were in a moment of jumping (becouse that state was not destroyed).. it may have funny efect when you fly into portal with 250 m/s hit it and have instant sloe 20 m/s speed as it was a speed when you was jumping before https://www.youtube.com/watch?v=xx5m0hJ8NTw (yawn) overally this is very interesting effect such interworlds jumping (see video)
Re: [pic] avoidance problem
Author: Chris M. Thomasson
Date: Thu, 26 Nov 2026 20:58
Date: Thu, 26 Nov 2026 20:58
24 lines
2213 bytes
2213 bytes
On 11/25/2026 4:52 PM, fir wrote: > fir pisze: [...] > > https://www.youtube.com/watch?v=xx5m0hJ8NTw > > (yawn) > > overally this is very interesting effect such interworlds jumping (see > video) > Have you played Portal 2? :^) Also, for those trail objects, are you instancing them? You must have some sort of "cutoff" right? Have some of them "expire" after a certain amount of time akin to a limited particle system? All on the CPU... Well, it seems to be pretty good. You should add a FPS text element. So we can see if it drops after a shit load of instances are created. Your geometry is pretty simple. Also, I noticed that some of the objects can overdraw your text from time to time. Probably want to render that last.
Re: [pic] avoidance problem
Author: Chris M. Thomasson
Date: Thu, 26 Nov 2026 21:28
Date: Thu, 26 Nov 2026 21:28
59 lines
3635 bytes
3635 bytes
On 11/25/2026 4:52 PM, fir wrote: > fir pisze: >> not ebtw how great ai is >> >> https://www.youtube.com/watch?v=Bi7XPFZBwTE >> >> tired on stessing on doing those pilot combat routines >> (which is stressful) i thinked today - maybe i should jump >> to another world, thus i need round portals to fly thru - >> >> and i made my first inter world jump >> >> (jump i coded but ai done a dettection of moment of it when passing >> portal >> plane which if no it would take longer) >> >> see the video of one of my first interdimensional jumps >> (ofc i jumped in hiperspace in old elite but those jumps here are better) >> >> those worlds i jump among are quite separate but out of simplicity put >> same things in same positions but later i will change it..so teh gates >> to new worlds become opan and its always good..iznt it?) >> >> fir >> > > > maybe some interesting curiosities as to this inter traweling to other > worlds > > first version was the part of teh world data was destroyed when leaving > the world and then reinitialized as like at game start (i did it becouse > it was faster) - curiosity is hat that those big asteroids positions was > based on rand() and rand was no reinitialised so there was a chance that > you go back thru portal but now asteroid is just after the portal and > you smash hard on it (did that twice or 3-4 times) > > now repaired and just data of given world is preserved(just not > destroyed) but it makes another curious behaviour > > when you travel first time you get located at 0,0,0 point but when you > back you will jump to exact time and position you were in a moment of > jumping (becouse that state was not destroyed).. it may have funny efect > when you fly into portal with 250 m/s hit it and have instant sloe 20 m/ > s speed as it was a speed when you was jumping before > > https://www.youtube.com/watch?v=xx5m0hJ8NTw > > (yawn) > > overally this is very interesting effect such interworlds jumping (see > video) > Fwiw, here is some of my older work, throttled to 60fps. https://i.ibb.co/HLqfWYz6/image.png https://i.ibb.co/F4xNB2fk/image.png
Re: [pic] avoidance problem
Author: fir
Date: Thu, 26 Nov 2026 21:51
Date: Thu, 26 Nov 2026 21:51
46 lines
2928 bytes
2928 bytes
Chris M. Thomasson pisze: > On 11/25/2026 4:52 PM, fir wrote: >> fir pisze: > [...] >> >> https://www.youtube.com/watch?v=xx5m0hJ8NTw >> >> (yawn) >> >> overally this is very interesting effect such interworlds jumping (see >> video) >> > > Have you played Portal 2? :^) > > Also, for those trail objects, are you instancing them? You must have > some sort of "cutoff" right? Have some of them "expire" after a certain > amount of time akin to a limited particle system? > > All on the CPU... Well, it seems to be pretty good. You should add a FPS > text element. So we can see if it drops after a shit load of instances > are created. Your geometry is pretty simple. > > Also, I noticed that some of the objects can overdraw your text from > time to time. Probably want to render that last. i dropped the executalble on itch io https://lord-fir.itch.io/lean-fire-shots so some may run it ..indeed the last version have for me antidepressive outcome, good to run i dont know what is instancing in cpu you simply draw things, so its a stream of draws ;c those trails are used as i was coded moves and with trais i see move history and easier to judge what is ok whats wrong it uses int ttl - time to live, counted in frames if it drops to zero i disable record in array erasing a thing form execution and allowing its slot in array to be reused
Re: [pic] avoidance problem
Author: fir
Date: Fri, 27 Nov 2026 07:48
Date: Fri, 27 Nov 2026 07:48
64 lines
3691 bytes
3691 bytes
Chris M. Thomasson pisze: > On 11/25/2026 4:52 PM, fir wrote: >> fir pisze: > [...] >> >> https://www.youtube.com/watch?v=xx5m0hJ8NTw >> >> (yawn) >> >> overally this is very interesting effect such interworlds jumping (see >> video) >> > > Have you played Portal 2? :^) > never seen that overally those portals are very good idea, if i would throw all things is one location even if some being far it makes game choke...but whit many locations i can throw a lot in different locations (practically possibly unlimited i guess) and it make the game more artistic also(as it may compose different styles etc...extremally good idea thoug putting it inside those worlds is a lot of work now only added portals for some empty worlds but with time i will add something inside them https://www.youtube.com/watch?v=t3qVab4UHGo (though now im a bit sick) you may download it from itchio and check how it works probably it can work in linux wine though the controls may be maybe confusing https://lord-fir.itch.io/lean-fire-shots (flying and turning to camera dir is with rmb ( right mouse button), flying stright is lmb, shoting is lmb+rmb, mouse with no buttons is camera movement) lean fire shots is quite random name ..it comes from rewritting my green fire dll into lean fire version (like windows lean and mean) so this is lean fire and as it is shoter here its lean fire shots though Ai says it may mean something other also and i took it “Lean” here means sparse and restrained, almost aristocratically reserved — a deliberately modest amount of gunfire. > Also, for those trail objects, are you instancing them? You must have > some sort of "cutoff" right? Have some of them "expire" after a certain > amount of time akin to a limited particle system? > > All on the CPU... Well, it seems to be pretty good. You should add a FPS > text element. So we can see if it drops after a shit load of instances > are created. Your geometry is pretty simple. > > Also, I noticed that some of the objects can overdraw your text from > time to time. Probably want to render that last.
Re: [pic] avoidance problem
Author: fir
Date: Fri, 27 Nov 2026 09:32
Date: Fri, 27 Nov 2026 09:32
55 lines
3427 bytes
3427 bytes
fir pisze: > Chris M. Thomasson pisze: >> On 11/25/2026 4:52 PM, fir wrote: >>> fir pisze: >> [...] >>> >>> https://www.youtube.com/watch?v=xx5m0hJ8NTw >>> >>> (yawn) >>> >>> overally this is very interesting effect such interworlds jumping >>> (see video) >>> >> >> Have you played Portal 2? :^) >> >> Also, for those trail objects, are you instancing them? You must have >> some sort of "cutoff" right? Have some of them "expire" after a >> certain amount of time akin to a limited particle system? >> >> All on the CPU... Well, it seems to be pretty good. You should add a >> FPS text element. So we can see if it drops after a shit load of >> instances are created. Your geometry is pretty simple. >> >> Also, I noticed that some of the objects can overdraw your text from >> time to time. Probably want to render that last. > > i dropped the executalble on itch io > > https://lord-fir.itch.io/lean-fire-shots > > so some may run it ..indeed the last version have for me antidepressive > outcome, good to run > > > i dont know what is instancing in cpu you simply draw things, > so its a stream of draws ;c > > those trails are used as i was coded moves and with trais i see > move history and easier to judge what is ok whats wrong > > it uses int ttl - time to live, counted in frames if it drops to zero i > disable record in array erasing a thing form execution and allowing its > slot in array to be reused > > quite good if yore commenting this project..i may add then some name of pilot of somewhip as "Chris M. Thomasson " if you want (though im not implementing allied squadron yet)...im also not sure how much time i will get to ship it and it may just freeze in not shipped/not ended state for now the coding ent quite well though but i never know the moment i get burnt (burned out)
Re: [pic] avoidance problem
Author: Chris M. Thomasson
Date: Fri, 27 Nov 2026 22:05
Date: Fri, 27 Nov 2026 22:05
27 lines
1947 bytes
1947 bytes
On 11/26/2026 11:48 PM, fir wrote: > Chris M. Thomasson pisze: >> On 11/25/2026 4:52 PM, fir wrote: >>> fir pisze: >> [...] >>> >>> https://www.youtube.com/watch?v=xx5m0hJ8NTw >>> >>> (yawn) >>> >>> overally this is very interesting effect such interworlds jumping >>> (see video) >>> >> >> Have you played Portal 2? :^) >> > > never seen that Fwiw, its a pretty fun puzzle game: https://youtu.be/aph3szQ2bCQ [...]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads