Jump to content

[V2.4.1] Detecting ray hit with waterglobal


photo

Recommended Posts

Hi there!

I have an ObjectWaterGlobal and several materials inherited from water_global to create different beaufort intensities.

I have noticed that with the highest intensity, the raytracing to detect a bullet impact in the highest crest waves and in the deepest valley waves are failling.

Do you have any clue about what could be happening? Because I can't find anything that could cause this.

Attached the parameters of the material used

IMG_20220617_143744.jpg

IMG_20220617_143714.jpg

IMG_20220617_143730.jpg

Edited by Gmarquez
Link to comment

Hello!

@Gmarquez Since 2.4.1 are a little bit outdated at the moment it will be hard to tell what may cause this issue.

Could you please prepare a minimal test scene and send it to us so we can also reproduce the same behavior on our side?

Thanks!

Link to comment

Unfortunately I could not give you a test scene. The security protocols of the company dont allow the sharing of any code.

Also the simulation running in Unigine is embedded in another application and is impossible to extract a code snippet to create a sample.

I know it's hard to get help with those restrictions...

This is the reason because I was asking if some one could imagine some causes or roots for a problem of that kind, because I could find anything to follow and to try to get the root of the cause.

I have burn all the possibilities I had in mind but I didnt find anything.

Link to comment

We do understand that it may be problematic to get a proper reproduction, but in that case I guess it would be enough to do some very simplified test scene.

Default new world with only ObjectWaterGlobal with your tuned material settings and few lines of code with enabled visualizer that shows mentioned intersection issues should do the trick.

Intersection with big waves is always a challenge, so there might be some issues and imprecisions (in order to save some performance). And, unfortunately, in 2.4.1 there is no really any additional intersection parameters (unlike in recent 2.15.x) that we can tune to avoid this.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Well, the parameters of the ObjectWaterGlobal are the shown in the pictures and the code in charge of check the impact of the bullet with anything is the next

UNIGINE_VEC3 shot::hasImpacted(UNIGINE_VEC3 position)
{
  Unigine::Math::vec4 tempVec4;
  int tempInt;
  
  UNIGINE_VEC3 impactPoint(0.0);
  Unigine::Math::vec3 impactNormal(0.0);
  inf surface = 0;
  
  Unigine::ObjectPtr impact = Unigine::World::get()->getIntersection(mPositionPreviousCycle, position, 3, mExcludedNodes,
                                                                     &impactPoint, &impactNormal, &tempVec4, &tempInt, &surface);
  if (impact.get != nullptr && mIsCollisionEnabled)
  {
    checkImpactSurface(impact); //This check the object type and a property of the object to check what kind of physical material is the object
    mNodeImpact = util::Unigine::getParent(impact->getNode());
    if (mNodImpact->getType() != Unigine::Object::OBJECT_DUMMY)
    {
      mNodeImpact = Util::UnigineUtils::getRootParent(impact->getNode());
    }
    mSurfaceImpact = surface;
    
    showImpactDecals(impact, impactPoint); //With the kind of physical material, here it's selected the decal and particles to be shown
    showImpactParticles(impactPoint, impactNormal);
    
    mImpact = true;
  }
  return impactPoint;
}

The problem is that the getIntersection some times is null when clearly the bullet is crossing the ObjectWaterGlobal.

Link to comment

Thanks for the test code, but I'm afraid it's not enough to understand what happens here.

Is it possible to get a full test code and scene where we can see your water object and how intersection rays are being constructed, their length and orientation in 3D World? Maybe that will give us some clues how we can improve this situation.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
Posted (edited)

I know that this problem are gonna be hard to be supported be you.

I must to say that the tittle of the thread is not the more accurate I could set because as you can see in the code sample, the hit is not checked by rays but by getIntersections using as test points the position of the projectile in the actual frame and the position in the previous one.

I guess that the engine internaly perform a ray hit test and the distance between the test points varies over time because the projectile have a realistic ballistic calculation until it hit something and the node and all the related objects are destroyed.

Edited by Gmarquez
Link to comment
×
×
  • Create New...