Jump to content

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


Chiblue
 Share

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:

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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...

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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.

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

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...

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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?

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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...

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

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...

If it's not Tactical realism then you are just playing..

Link to comment
Share on other sites

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...

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

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...

If it's not Tactical realism then you are just playing..

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.

 Share

×
×
  • Create New...