Jump to content
Chiblue

Why doesn't any game engine have a working Raycast??

Recommended Posts

I initially started using DBPro, then I went to Dark GDK, for various reasons only to find out that thier all encompassing Dark PHysics failed to perform raycast accurately...

 

Now after spending several weeks with LE, and posting about this issue twice on the forums, Raycat in LE does not work, or rather is provides accurate collision reports but randomly HANGS for 500 or more miliseconds... which causes a major lag in my project and as a result makes it unviable as a FPS... I now understand why every time I have seen anything associated with bullet tracing is has been done with an object, rather than raycast... I posted a question concerning this a couple of weeks back and not once did anyone tell me Raycast dfoes not work...

 

So please can I get this issue fixed... I know this is not exactly a feature request but it seems my posts about raycast hanging have gone completely ignored...

 

I really like the LE Engine, but raycast is a critical part of my project requirements and without it I have no project... :lol:

Share this post


Link to post

Post an example that produces the problem.

 

What do you need, I posting in the programming C++ forum... my logs, timing and code...

 

I am performing the following cast...

 

int hit = EntityPick(&pickent,gun,weap->maximumrange,0,0,(BP)PickFilter);

 

This is my filter, although I have removed this and get the same results...

 

int _stdcall PickFilter( TEntity pickentity)
{
int EntType = GetEntityType(pickentity);
switch(EntType)
{
case 0:  // terrain
	return 1;
case 1:  // terrain
	return 1;	// <10 no force,  but effects..
case 2:  // terrain
	return 1;	// <10 no force,  but effects..
case 11: // Player
	return 0;
case 12:  // Freindly
	return 1;	// 10> force and effects.
case 14:  // props
	return 1;	// 10> force and effects.
case 21:  // Enemy
	return 1;
default:
	return 1;
}

}

 

I also tried this...

 

int hit = EntityPick(&pickent,gun,weap->maximumrange,0,0);

 

I placed an UpdateAppTime() and wrote a log file with the apptime before and after the raycast that hung... this happens every maybe 5-10 seconds in the game loop, only when I am firing or using my sight distance functions (bothe using raycast) one uses CameraPick the other EntityPick, I was trying to ensure that both cause the same problem, and they do..

 

This is the log record before and after the EntityPick/CameraPick...

 

12254122.000000 : PlayFPSAnimation - EntityPick

12254630.000000 : PlayFPSAnimation - EntityPick Done

 

AQs you can see the function on this case took 500 miliseconds... which causes a significant lag in gameplay...

 

 

I am using a scene created with Editor, all entities have types associated with them... I cannot be sure but the problem seems most prevelant when you intersect the terrain... but as I said this is only conjecture...Also it appears to happen when moving rotating i.e. changing the raycast results...

Share this post


Link to post

I will try and get you something tomorrow but the problem can be easily teplicated.... Create a scene in editor then do a camerapick every iteration of the game loop and this with represent the same environment. I have even removed the filter call back and still have the problem....

 

You will not be able to run my code without all models textures and 3rd party classes.. I will try and create a simulation of the problem.

Share this post


Link to post

How far is your z component of the CameraPick? I would imagine the higher that distance the slower it would be.

 

I have a CameraPick() every iteration of the game loop using CameraPick(&p, camera, Vec3(MouseX(), MouseY(), 5000)); and I don't see any drops in my frame rate.

Share this post


Link to post

The z is set to 3000, I cannot be sure but I believe that the hang happens when the pick hits terrain after hitting an object my test scene basically has a terrain with high mounds surrounding an area with grass, barrels and some trees all objects in the scene are standard ones shipped with LE. I removed all custom models incase that was causing the issue. The only other change is that I am trying to get decals to work which is not yet working but may this causes the problem. Although I have seen the hang happen from first start i

up.

 

Do you have impacts on terrain? I wish I could be more specific, could there be an issue with OpenGL? Or the windows sdk? What versions of these are you using?

Share this post


Link to post

That camera pick I posted was what I do on the terrain. It's how I select where I want a unit to move to. I have version 2.31.

 

The below code is what gets called every frame

 

TPick p;
p.entity = 0;
CameraPick(&p, camera, Vec3(MouseX(), MouseY(), 5000), 0, 1);

// we only care about the terrain
string cls = "";
if(p.entity != 0)
	cls = GetEntityKey(p.entity, "classname", "");

if(cls == "Terrain")
{
	ShowEntity(GetAoECursor()->GetPlane());
	PositionEntity(GetAoECursor()->GetPlane(), Vec3(p.X - 10, p.Y, p.Z - 10));	// -10 is 1/2 the scale of the plane
	GetAoECursor()->Update();
}

Share this post


Link to post

The only difference I see is that you are specifically selecting collision type 1, maybe becuase I am allowing all collisino types, transitioning from one to another is causing the problem?? not sure why this would matter... but like I said it seems the function hangs when I transition between one entity and another... i.e. Barrels and terrain...

Share this post


Link to post

I need source code for a program I can run to see a problem.

I really can't send the entire project even compressed it's over 200mb.. what exactly do you need?

 

If I send you the editor file and the EntityPick function... I am not sure what else would influence this?

Share this post


Link to post

Ok I fixed my problem, well found a work around.. if I remove all entities from the scene and only have the terrain, I no longer have the hangup in the raycast... So what this means I am not quite sure...

 

The one thing I have done in the scene is changed the entity types to be within logical ranges... i.e. Terrain and fixed scene entities have a type of 1 to 10 depending upon thier type, i.e. trees, buildings, terrain etc... Props like oildrum are also in this range... Friendly entities like all player objects are 11 and friendly entities between 12 and 20, enemy entities are 21 to 30... could it be that becuase of these ranges the collision detection is hanging when the raycast moves from an entity type of 21 and the next closest collision is 1...

 

Just a thought...

Share this post


Link to post

I can't tell what the problem is from your description of your scene. However, a 4000 unit long raytrace could be a very expensive operation in some situations.

Share this post


Link to post

I understand that, about the 4000 z trace... sorry I did not make myself clear... due to the problems I am having with the camera rendering, I took my scene and removed every object except the terrain and the starting location class... this did not help the rendering issue, but when I use the raytrace there is no longer a pause.. so given that others in this post are raycasting a fair distance more or less the same...

 

Also given that my scene only includes standard Editor objects oildrum etc... then it comes down to what is different... and my only change is that I changed all the collision types, only terrain and veg are the same... all others are different, and they range from 10 to 30 depending upon the game interaction I want... I am not using 30 entity types but I am using 11, 12 then 21...

 

So I was wondering if the entity types used in the collisions are not close numbers does te raycast look for next entity types... i.e. 1,2,3,4, this would explain my behaviour but I do not know how the raycast was implemented so I cannot state this... I guess I should return to the preset collision types and see what happens...

Share this post


Link to post

500 milliseconds of lag, that lag in your log timing could be from the latency required to write the data to your log or print to the console...

Share this post


Link to post

500 milliseconds of lag, that lag in your log timing could be from the latency required to write the data to your log or print to the console...

 

I turned the log on to try and understand waht was happeing with the raycast... If I create a scene without any objects raycast works fine, but it seems that when I do one cast and hit an object, then do another which hits a different object it lags.. but not always... seems that from object to terrain lags... I understand this does not make sense, but this is the only pattern I have seen... and the log basically pinpointed that the lag is the cast, if I remove the case then I get no lag...

Share this post


Link to post

Not sure if this was address above but are you able to provide the whole project for us? Or maybe a smaller version of it producing the same issues?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...