Jump to content

Get contact object surface


photo

Recommended Posts

Posted

I set Body::setContactCallback() to determine surface, that is collided with physical body. I use next callback:

		void eventBodyContactGlobal(Body body, int contact)
		{
			Object object1 = body.getObject();
			Object object2 = body.getContactObject(contact);

			Property prop1 = object1.getProperty(); // I need get properties of physical object

			int surfaceIndex = body.getContactSurface(contact);

			if (object2 != NULL && surfaceIndex < object2.getNumSurfaces())
			{
				Property prop2 = object2.getProperty(surfaceIndex); // I need get properties of collided object (it's surface's properties)
			}
		}

This implementation crash Unigine. What I doing wrong?

Posted

This implementation crash Unigine. What I doing wrong?

 

Just an idea: also check surfaceIndex returned by body.getContactSurface(contact) for negativ value. If this is the case, this might be the cause for the crash due to invalid array access on following object2.getProperty(surfaceIndex) call.

×
×
  • Create New...