From 234bd476f3af6ada000eb1ede76c7f48995df304 Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Thu, 25 Apr 2019 19:46:36 -0700 Subject: [PATCH] implement contact-response for jme3-jbullet's PhysicsRigidBody --- .../jme3/bullet/objects/PhysicsRigidBody.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java index 2d318e97c..d585c2001 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -279,12 +279,17 @@ public class PhysicsRigidBody extends PhysicsCollisionObject { /** * Enable/disable this body's contact response. * - * @param newState true to respond to contacts (default=true) + * @param responsive true to respond to contacts, false to ignore them + * (default=true) */ - public void setContactResponse(boolean newState) { - if (!newState) { - throw new UnsupportedOperationException("Not implemented."); + public void setContactResponse(boolean responsive) { + int flags = rBody.getCollisionFlags(); + if (responsive) { + flags &= ~CollisionFlags.NO_CONTACT_RESPONSE; + } else { + flags |= CollisionFlags.NO_CONTACT_RESPONSE; } + rBody.setCollisionFlags(flags); } /** @@ -293,7 +298,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject { * @return true if responsive, otherwise false */ public boolean isContactResponse() { - return true; + int flags = rBody.getCollisionFlags(); + boolean result = (flags & CollisionFlags.NO_CONTACT_RESPONSE) == 0x0; + return result; } public void setCcdSweptSphereRadius(float radius) {