This commit is contained in:
parent
cde3c39c4f
commit
d8acd30a27
@ -102,6 +102,7 @@ public class CharacterControl extends PhysicsCharacter implements PhysicsControl
|
|||||||
control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
|
control.setCcdSweptSphereRadius(getCcdSweptSphereRadius());
|
||||||
control.setCollideWithGroups(getCollideWithGroups());
|
control.setCollideWithGroups(getCollideWithGroups());
|
||||||
control.setCollisionGroup(getCollisionGroup());
|
control.setCollisionGroup(getCollisionGroup());
|
||||||
|
control.setContactResponse(isContactResponse());
|
||||||
control.setFallSpeed(getFallSpeed());
|
control.setFallSpeed(getFallSpeed());
|
||||||
control.setGravity(getGravity());
|
control.setGravity(getGravity());
|
||||||
control.setJumpSpeed(getJumpSpeed());
|
control.setJumpSpeed(getJumpSpeed());
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.bullet.objects;
|
package com.jme3.bullet.objects;
|
||||||
|
|
||||||
|
import com.jme3.bullet.collision.CollisionFlag;
|
||||||
import com.jme3.bullet.collision.PhysicsCollisionObject;
|
import com.jme3.bullet.collision.PhysicsCollisionObject;
|
||||||
import com.jme3.bullet.collision.shapes.CollisionShape;
|
import com.jme3.bullet.collision.shapes.CollisionShape;
|
||||||
import com.jme3.export.InputCapsule;
|
import com.jme3.export.InputCapsule;
|
||||||
@ -50,7 +51,6 @@ import java.util.logging.Logger;
|
|||||||
* @author normenhansen
|
* @author normenhansen
|
||||||
*/
|
*/
|
||||||
public class PhysicsCharacter extends PhysicsCollisionObject {
|
public class PhysicsCharacter extends PhysicsCollisionObject {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique identifier of btKinematicCharacterController (as opposed to its
|
* Unique identifier of btKinematicCharacterController (as opposed to its
|
||||||
* collision object, which is a ghost). Constructors are responsible for
|
* collision object, which is a ghost). Constructors are responsible for
|
||||||
@ -456,6 +456,22 @@ public class PhysicsCharacter extends PhysicsCollisionObject {
|
|||||||
|
|
||||||
private native float getMaxSlope(long characterId);
|
private native float getMaxSlope(long characterId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/disable this character's contact response.
|
||||||
|
*
|
||||||
|
* @param responsive true to respond to contacts, false to ignore them
|
||||||
|
* (default=true)
|
||||||
|
*/
|
||||||
|
public void setContactResponse(boolean responsive) {
|
||||||
|
int flags = getCollisionFlags(objectId);
|
||||||
|
if (responsive) {
|
||||||
|
flags &= ~CollisionFlag.NO_CONTACT_RESPONSE;
|
||||||
|
} else {
|
||||||
|
flags |= CollisionFlag.NO_CONTACT_RESPONSE;
|
||||||
|
}
|
||||||
|
setCollisionFlags(objectId, flags);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether this character is on the ground.
|
* Test whether this character is on the ground.
|
||||||
*
|
*
|
||||||
|
@ -57,12 +57,6 @@ import java.util.logging.Logger;
|
|||||||
* @author normenhansen
|
* @author normenhansen
|
||||||
*/
|
*/
|
||||||
public class PhysicsRigidBody extends PhysicsCollisionObject {
|
public class PhysicsRigidBody extends PhysicsCollisionObject {
|
||||||
|
|
||||||
/**
|
|
||||||
* copy of the contact response state: true→responds to contacts,
|
|
||||||
* false→doesn't respond (default=true)
|
|
||||||
*/
|
|
||||||
private boolean contactResponseState = true;
|
|
||||||
/**
|
/**
|
||||||
* motion state
|
* motion state
|
||||||
*/
|
*/
|
||||||
@ -390,8 +384,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|||||||
flags |= CollisionFlag.NO_CONTACT_RESPONSE;
|
flags |= CollisionFlag.NO_CONTACT_RESPONSE;
|
||||||
}
|
}
|
||||||
setCollisionFlags(objectId, flags);
|
setCollisionFlags(objectId, flags);
|
||||||
|
|
||||||
contactResponseState = responsive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2012 jMonkeyEngine
|
* Copyright (c) 2009-2018 jMonkeyEngine
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -169,6 +169,26 @@ public class PhysicsCharacter extends PhysicsCollisionObject {
|
|||||||
return character.getMaxSlope();
|
return character.getMaxSlope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/disable this body's contact response.
|
||||||
|
*
|
||||||
|
* @param newState true to respond to contacts (default=true)
|
||||||
|
*/
|
||||||
|
public void setContactResponse(boolean newState) {
|
||||||
|
if (!newState) {
|
||||||
|
throw new UnsupportedOperationException("Not implemented.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether this body responds to contacts.
|
||||||
|
*
|
||||||
|
* @return true if responsive, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean isContactResponse() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onGround() {
|
public boolean onGround() {
|
||||||
return character.onGround();
|
return character.onGround();
|
||||||
}
|
}
|
||||||
@ -279,6 +299,7 @@ public class PhysicsCharacter extends PhysicsCollisionObject {
|
|||||||
buildObject();
|
buildObject();
|
||||||
character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
|
character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
|
||||||
setGravity(capsule.readFloat("gravity", 9.8f * 3));
|
setGravity(capsule.readFloat("gravity", 9.8f * 3));
|
||||||
|
setContactResponse(capsule.readBoolean("contactResponse", true));
|
||||||
setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
|
setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
|
||||||
setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
|
setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
|
||||||
setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
|
setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user