Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlap function for BVHtree not working in BGE #786

Closed
RomStef opened this issue Aug 10, 2018 · 14 comments
Closed

overlap function for BVHtree not working in BGE #786

RomStef opened this issue Aug 10, 2018 · 14 comments

Comments

@RomStef
Copy link

RomStef commented Aug 10, 2018

as i said in the title , when i call the overlap function of BVHtree for testing overlapped faces between two different BVHtree the programm says the object has no attribute 'overlap'

@lordloki
Copy link
Member

Could you attach a little example?

@panzergame
Copy link
Contributor

I could not reproduce this bug on linux with:

mesh =mesh.constructBvh().overlap(mesh.constructBvh())

@RomStef
Copy link
Author

RomStef commented Aug 10, 2018

with no example , i have try just like the mathutils BVHtree :

"""
import bge
import mathutils

#Objects

water = bge.logic.getCurrentController().owner
terrain = bge.logic.getCurrentScene().objects['terrain']

#Meshes
waterMesh = water.meshes[0]
terrainMesh = terrain.meshes[0]

#BVHtrees
waterBVHTree = waterMesh.constructBvh
terrainBVHTree = terrainMesh.constructBvh

#Test overlapped faces
overlappedFacesList = terrainBVHTree.overlap(waterBVHTree)
overlappedFacesList.sort()

print(overlappedFacesList)
"""

where water and terrain are two intersected planes

@RomStef RomStef closed this as completed Aug 10, 2018
@RomStef RomStef reopened this Aug 10, 2018
@RomStef RomStef closed this as completed Aug 10, 2018
@RomStef
Copy link
Author

RomStef commented Aug 10, 2018

i have missed the brackets , sorry

@RomStef
Copy link
Author

RomStef commented Aug 14, 2018

Sorry, i have to return on this issue because the overlap function work but don't return any value.
here an example :
Uploading test_bvh_overlap.zip…

@RomStef RomStef reopened this Aug 14, 2018
@panzergame
Copy link
Contributor

@RomStef : the file link seems incorrect.

@RomStef
Copy link
Author

RomStef commented Aug 14, 2018

test_bvh_overlap.zip

@panzergame panzergame added the bug label Aug 14, 2018
@panzergame
Copy link
Contributor

The BVH is construct from the mesh and can't include the object transformation because meshes are shared.
In your example file, the water plane have a transformation and without it it doesn't intersect the ground. Applying the location on the plane mesh is fixing the issue.

Though a lot of people will encounter this issue, @RomStef, @BluePrintRandom: Do you think interesting to pass a matrix to constructBvh to represent the object transformation ?

@panzergame panzergame removed the bug label Aug 14, 2018
@panzergame
Copy link
Contributor

@RomStef, @BluePrintRandom ?

@BluePrintRandom
Copy link
Member

BluePrintRandom commented Aug 26, 2018 via email

@panzergame
Copy link
Contributor

The mesh can't get a world transform as it is shared across objects, I will make PR tonight for passing a matrix.

panzergame added a commit that referenced this issue Aug 26, 2018
The function KX_Mesh.constructBvh can now use as first argument
a transform 4x4 matrix used over all the vertices. This allow
the user to create a BVH in world space by passing the object
world transform.

Fix issue #786.
panzergame added a commit that referenced this issue Sep 1, 2018
The function KX_Mesh.constructBvh can now use as first argument
a transform 4x4 matrix used over all the vertices. This allow
the user to create a BVH in world space by passing the object
world transform.

Fix issue #786.
@vlad0337187
Copy link

Strange, but in my case, seems, player and some cubes intersect always, regardless they don't actually intersect.

Example: https://www.youtube.com/watch?v=4Lsk84Gb9TY

Here you see, that BVHTree always says that there are some intersected faces, but if you'll look to coordinates, than you'll see that they'll be the same only when I jumped on one of that blocks.

Can somebody tell me, what I'm doing wrong ?)

@BluePrintRandom
Copy link
Member

BluePrintRandom commented Nov 30, 2018 via email

@vlad0337187
Copy link

@BluePrintRandom , ah, no.
Thanks )
I missed that, I thought, that it was fixed in PR to account that transfor automatically =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants