Merge branch 'master' of github.com:highfidelity/hifi into tablet-ui-edit-js

This commit is contained in:
Seth Alves 2017-03-07 11:42:44 -08:00
commit b938579598
4 changed files with 36 additions and 8 deletions

View file

@ -163,7 +163,7 @@ void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
// This value specifes how the shape should be treated by physics calculations. // This value specifes how the shape should be treated by physics calculations.
// For now, all polys will act as spheres // For now, all polys will act as spheres
ShapeType ShapeEntityItem::getShapeType() const { ShapeType ShapeEntityItem::getShapeType() const {
return (_shape == entity::Shape::Cube) ? SHAPE_TYPE_BOX : SHAPE_TYPE_SPHERE; return (_shape == entity::Shape::Cube) ? SHAPE_TYPE_BOX : SHAPE_TYPE_ELLIPSOID;
} }
void ShapeEntityItem::setColor(const rgbColor& value) { void ShapeEntityItem::setColor(const rgbColor& value) {

View file

@ -256,9 +256,20 @@ const btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info)
} }
break; break;
case SHAPE_TYPE_SPHERE: { case SHAPE_TYPE_SPHERE: {
glm::vec3 halfExtents = info.getHalfExtents();
float radius = glm::max(halfExtents.x, glm::max(halfExtents.y, halfExtents.z));
shape = new btSphereShape(radius);
}
break;
case SHAPE_TYPE_ELLIPSOID: {
glm::vec3 halfExtents = info.getHalfExtents(); glm::vec3 halfExtents = info.getHalfExtents();
float radius = halfExtents.x; float radius = halfExtents.x;
if (radius == halfExtents.y && radius == halfExtents.z) { const float MIN_RADIUS = 0.001f;
const float MIN_RELATIVE_SPHERICAL_ERROR = 0.001f;
if (radius > MIN_RADIUS
&& fabsf(radius - halfExtents.y) / radius < MIN_RELATIVE_SPHERICAL_ERROR
&& fabsf(radius - halfExtents.z) / radius < MIN_RELATIVE_SPHERICAL_ERROR) {
// close enough to true sphere
shape = new btSphereShape(radius); shape = new btSphereShape(radius);
} else { } else {
ShapeInfo::PointList points; ShapeInfo::PointList points;

View file

@ -45,7 +45,8 @@ enum ShapeType {
SHAPE_TYPE_COMPOUND, SHAPE_TYPE_COMPOUND,
SHAPE_TYPE_SIMPLE_HULL, SHAPE_TYPE_SIMPLE_HULL,
SHAPE_TYPE_SIMPLE_COMPOUND, SHAPE_TYPE_SIMPLE_COMPOUND,
SHAPE_TYPE_STATIC_MESH SHAPE_TYPE_STATIC_MESH,
SHAPE_TYPE_ELLIPSOID
}; };
class ShapeInfo { class ShapeInfo {

View file

@ -51,7 +51,9 @@ const OUTPUT_DEVICE_SETTING = "audio_output_device";
var selectedInputMenu = ""; var selectedInputMenu = "";
var selectedOutputMenu = ""; var selectedOutputMenu = "";
var audioDevicesList = [];
function setupAudioMenus() { function setupAudioMenus() {
removeAudioMenus();
Menu.addSeparator("Audio", "Input Audio Device"); Menu.addSeparator("Audio", "Input Audio Device");
var inputDeviceSetting = Settings.getValue(INPUT_DEVICE_SETTING); var inputDeviceSetting = Settings.getValue(INPUT_DEVICE_SETTING);
@ -67,11 +69,12 @@ function setupAudioMenus() {
var thisDeviceSelected = (inputDevices[i] == selectedInputDevice); var thisDeviceSelected = (inputDevices[i] == selectedInputDevice);
var menuItem = "Use " + inputDevices[i] + " for Input"; var menuItem = "Use " + inputDevices[i] + " for Input";
Menu.addMenuItem({ Menu.addMenuItem({
menuName: "Audio", menuName: "Audio",
menuItemName: menuItem, menuItemName: menuItem,
isCheckable: true, isCheckable: true,
isChecked: thisDeviceSelected isChecked: thisDeviceSelected
}); });
audioDevicesList.push(menuItem);
if (thisDeviceSelected) { if (thisDeviceSelected) {
selectedInputMenu = menuItem; selectedInputMenu = menuItem;
} }
@ -97,12 +100,24 @@ function setupAudioMenus() {
isCheckable: true, isCheckable: true,
isChecked: thisDeviceSelected isChecked: thisDeviceSelected
}); });
audioDevicesList.push(menuItem);
if (thisDeviceSelected) { if (thisDeviceSelected) {
selectedOutputMenu = menuItem; selectedOutputMenu = menuItem;
} }
} }
} }
function removeAudioMenus() {
Menu.removeSeparator("Audio", "Input Audio Device");
Menu.removeSeparator("Audio", "Output Audio Device");
for (var index = 0; index < audioDevicesList.length; index++) {
Menu.removeMenuItem("Audio", audioDevicesList[index]);
}
audioDevicesList = [];
}
function onDevicechanged() { function onDevicechanged() {
print("audio devices changed, removing Audio > Devices menu..."); print("audio devices changed, removing Audio > Devices menu...");
Menu.removeMenu("Audio > Devices"); Menu.removeMenu("Audio > Devices");
@ -218,6 +233,7 @@ Script.update.connect(checkHMDAudio);
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
restoreAudio(); restoreAudio();
removeAudioMenus();
Menu.menuItemEvent.disconnect(menuItemEvent); Menu.menuItemEvent.disconnect(menuItemEvent);
Script.update.disconnect(checkHMDAudio); Script.update.disconnect(checkHMDAudio);
}); });