Archived

This topic is now archived and is closed to further replies.

BlueChip

Collision about irregular geometry

Recommended Posts

Hi folks... In the my engine, usually I use a BB collision... but if I use big irregular geometries (like terrain, hills, caves) I must use a precise collision system, i.e I must check if there is a collision with each triangle of my model... This is a bad work? I must lock and unlock my VB every frame... I don''t like it, but I can''t see other ways what you think about this problem? bye.

Share this post


Link to post
Share on other sites
I have a full array of vertices/faces in memory.

When I create my VB, I lock it, copy the array data into it, then unlock it.

From this point on, I draw the VB contents, but I test my arrays for collisions/movements/etc...

When its time to modify my VB, I re-lock it, copy again, then unlock it..

So basically I use my in-memory array for testing, and not the VB contents, per frame.



www.cppnow.com

Share this post


Link to post
Share on other sites
Oh yes Superdeveloper.... I like this very much...
so, if I don''t change my model... I don''t must lock and unlock my VB...

easy, fast and clear... so good..
yep... =)
thanks

Share this post


Link to post
Share on other sites
If your vertex buffers are MANAGED, then you don''t need to do this. Direct3D holds a system memory copy of managed resources.
So if you lock these vertex buffers, it''s going to return a pointer to that system memory buffer. Make sure you use the READONLY flag.

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites
ehmmm I use the D3DXMESH_MANAGED flag, but if I don''t lock my buffer, I get an error at run time, because my application can''t read the buffer...

and if I switch D3DXMESH_MANAGED with D3DXMESH_WRITEONLY in the method D3DXLoadMeshFromX, the application go down...

Perhaps I don''t understand your participation Code....

Share this post


Link to post
Share on other sites
quote:
ehmmm I use the D3DXMESH_MANAGED flag, but if I don''t lock my buffer, I get an error at run time, because my application can''t read the buffer...

I assume you mean "if I lock my buffer, I get an error".
This doesn''t mean managed buffers can''t be locked. The way managed buffers survive a device reset is this: D3D uses the system memory copy to restore the video memory one.

What debug output did you get when it failed? What HRESULT?
If you''ve not checked for these, do so now.

quote:
and if I switch D3DXMESH_MANAGED with D3DXMESH_WRITEONLY in the method D3DXLoadMeshFromX, the application go down...

I said READONLY, on the Lock() call: D3DLOCK_READONLY.
Buffers created with WRITEONLY will fail on any attempt to read the data:
[SDK Doc]
Informs the system that the application writes only to the vertex buffer. Using this flag enables the driver to choose the best memory location for efficient write operations and rendering. Attempts to read from a vertex buffer that is created with this capability will fail. Buffers created with D3DPOOL_DEFAULT that do not specify D3DUAGE_WRITEONLY might suffer a severe performance penalty.
[/SDK Doc]

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites
no... if I _don''t_ lock my buffer, I get an error.

I lock the buffer... then for each vertex I read his position...
If I don''t lock the buffer, in the variable Position (where I save the vertex position) nothing is put in, and I get an Access Violation.


For second part of your topic, in the afternoon I''ll try to do it.

Bye e thanks again.

Share this post


Link to post
Share on other sites
quote:
no... if I _don''t_ lock my buffer, I get an error.

I lock the buffer... then for each vertex I read his position...
If I don''t lock the buffer, in the variable Position (where I save the vertex position) nothing is put in, and I get an Access Violation.


It seems to me that you''re trying to read the vertex data from a pointer that''s not obtained using a Lock()?
Of course, this won''t work. You need to lock the buffer to get a valid pointer, and the pointer isn''t guaranteed to be valid after you unlock the buffer (i.e. you can''t store it for later usage)

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites