mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-18 15:32:02 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into zones
This commit is contained in:
commit
d18229d52d
9 changed files with 49 additions and 94 deletions
|
@ -30,7 +30,7 @@ print("zoneEntityA:" + zoneEntityA);
|
|||
|
||||
var zoneEntityB = Entities.addEntity({
|
||||
type: "Zone",
|
||||
position: { x: 1, y: 1, z: 21 },
|
||||
position: { x: 5, y: 5, z: 5 },
|
||||
dimensions: { x: 2, y: 2, z: 2 },
|
||||
keyLightColor: { red: 0, green: 255, blue: 0 },
|
||||
keyLightIntensity: 0.9,
|
||||
|
@ -47,7 +47,7 @@ print("zoneEntityB:" + zoneEntityB);
|
|||
|
||||
var zoneEntityC = Entities.addEntity({
|
||||
type: "Zone",
|
||||
position: { x: 5, y: 5, z: 15 },
|
||||
position: { x: 5, y: 10, z: 5 },
|
||||
dimensions: { x: 10, y: 10, z: 10 },
|
||||
keyLightColor: { red: 0, green: 0, blue: 255 },
|
||||
keyLightIntensity: 0.75,
|
||||
|
|
|
@ -1744,10 +1744,9 @@ void Application::setActiveFaceTracker() {
|
|||
DependencyManager::get<Faceshift>()->setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift));
|
||||
#endif
|
||||
#ifdef HAVE_DDE
|
||||
bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::DDEFaceRegression);
|
||||
bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::UseCamera);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::UseAudioForMouth)->setVisible(isUsingDDE);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::DDEFiltering)->setVisible(isUsingDDE);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::ResetDDETracking)->setVisible(isUsingDDE);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::VelocityFilter)->setVisible(isUsingDDE);
|
||||
DependencyManager::get<DdeFaceTracker>()->setEnabled(isUsingDDE);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ Menu::Menu() {
|
|||
faceTrackerGroup->addAction(faceshiftFaceTracker);
|
||||
#endif
|
||||
#ifdef HAVE_DDE
|
||||
QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::DDEFaceRegression,
|
||||
QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseCamera,
|
||||
0, false,
|
||||
qApp, SLOT(setActiveFaceTracker()));
|
||||
faceTrackerGroup->addAction(ddeFaceTracker);
|
||||
|
@ -381,13 +381,8 @@ Menu::Menu() {
|
|||
faceTrackingMenu->addSeparator();
|
||||
QAction* useAudioForMouth = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseAudioForMouth, 0, true);
|
||||
useAudioForMouth->setVisible(false);
|
||||
QAction* ddeFiltering = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::DDEFiltering, 0, true);
|
||||
QAction* ddeFiltering = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::VelocityFilter, 0, true);
|
||||
ddeFiltering->setVisible(false);
|
||||
QAction* ddeFaceTrackerReset = addActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::ResetDDETracking,
|
||||
Qt::CTRL | Qt::Key_Apostrophe,
|
||||
DependencyManager::get<DdeFaceTracker>().data(), SLOT(resetTracking()));
|
||||
ddeFaceTrackerReset->setVisible(false);
|
||||
faceTrackingMenu->addAction(ddeFaceTrackerReset);
|
||||
#endif
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSkeletonCollisionShapes);
|
||||
|
|
|
@ -130,8 +130,6 @@ namespace MenuOption {
|
|||
const QString ControlWithSpeech = "Control With Speech";
|
||||
const QString CopyAddress = "Copy Address to Clipboard";
|
||||
const QString CopyPath = "Copy Path to Clipboard";
|
||||
const QString DDEFaceRegression = "DDE Face Regression";
|
||||
const QString DDEFiltering = "DDE Filtering";
|
||||
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
||||
const QString DeleteBookmark = "Delete Bookmark...";
|
||||
const QString DisableActivityLogger = "Disable Activity Logger";
|
||||
|
@ -224,7 +222,6 @@ namespace MenuOption {
|
|||
const QString RenderAmbientLight8 = "CAMPUS_SUNSET";
|
||||
const QString RenderAmbientLight9 = "FUNSTON_BEACH_SUNSET";
|
||||
const QString ResetAvatarSize = "Reset Avatar Size";
|
||||
const QString ResetDDETracking = "Reset DDE Tracking";
|
||||
const QString ResetSensors = "Reset Sensors";
|
||||
const QString RunningScripts = "Running Scripts";
|
||||
const QString RunTimingTests = "Run Timing Tests";
|
||||
|
@ -247,6 +244,8 @@ namespace MenuOption {
|
|||
const QString TransmitterDrive = "Transmitter Drive";
|
||||
const QString TurnWithHead = "Turn using Head";
|
||||
const QString UseAudioForMouth = "Use Audio for Mouth";
|
||||
const QString UseCamera = "Use Camera";
|
||||
const QString VelocityFilter = "Velocity Filter";
|
||||
const QString VisibleToEveryone = "Everyone";
|
||||
const QString VisibleToFriends = "Friends";
|
||||
const QString VisibleToNoOne = "No one";
|
||||
|
|
|
@ -200,7 +200,7 @@ void DdeFaceTracker::setEnabled(bool enabled) {
|
|||
qDebug() << "[Info] DDE Face Tracker Starting";
|
||||
_ddeProcess = new QProcess(qApp);
|
||||
connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
|
||||
_ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS);
|
||||
_ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS, QIODevice::ReadOnly);
|
||||
}
|
||||
|
||||
if (!enabled && _ddeProcess) {
|
||||
|
@ -222,10 +222,14 @@ void DdeFaceTracker::processFinished(int exitCode, QProcess::ExitStatus exitStat
|
|||
}
|
||||
}
|
||||
|
||||
void DdeFaceTracker::resetTracking() {
|
||||
void DdeFaceTracker::reset() {
|
||||
_reset = true;
|
||||
|
||||
qDebug() << "[Info] Reset DDE Tracking";
|
||||
const char* DDE_RESET_COMMAND = "reset";
|
||||
_udpSocket.writeDatagram(DDE_RESET_COMMAND, DDE_SERVER_ADDR, _controlPort);
|
||||
|
||||
_reset = true;
|
||||
}
|
||||
|
||||
bool DdeFaceTracker::isActive() const {
|
||||
|
@ -281,7 +285,7 @@ float DdeFaceTracker::getBlendshapeCoefficient(int index) const {
|
|||
|
||||
void DdeFaceTracker::decodePacket(const QByteArray& buffer) {
|
||||
if(buffer.size() > MIN_PACKET_SIZE) {
|
||||
bool isFiltering = Menu::getInstance()->isOptionChecked(MenuOption::DDEFiltering);
|
||||
bool isFiltering = Menu::getInstance()->isOptionChecked(MenuOption::VelocityFilter);
|
||||
|
||||
Packet packet;
|
||||
int bytesToCopy = glm::min((int)sizeof(packet), buffer.size());
|
||||
|
|
|
@ -28,7 +28,7 @@ class DdeFaceTracker : public FaceTracker, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
virtual void reset() { _reset = true; }
|
||||
virtual void reset();
|
||||
|
||||
virtual bool isActive() const;
|
||||
virtual bool isTracking() const { return isActive(); }
|
||||
|
@ -50,7 +50,6 @@ public:
|
|||
|
||||
public slots:
|
||||
void setEnabled(bool enabled);
|
||||
void resetTracking();
|
||||
|
||||
private slots:
|
||||
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
|
|
@ -396,67 +396,14 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::R
|
|||
|
||||
_tree->lockForRead();
|
||||
|
||||
// Implement some kind of a stack/union mechanism here...
|
||||
//
|
||||
// * As you enter a zone (A), you use it's properties
|
||||
// * if already in a zone, and you enter the union of that zone and a new zone (A + B)
|
||||
// you use the settings of the new zone (B) you entered.. but remember that you were previously
|
||||
// in zone A
|
||||
// * if you enter a new zone and are in the union of 3 zones (A+B+C) then use zone C and remember
|
||||
// you were most recently in B
|
||||
_lastZones = _currentZones;
|
||||
_currentZones.clear();
|
||||
// Whenever you're in an intersection between zones, we will always choose the smallest zone.
|
||||
_bestZone = NULL;
|
||||
_bestZoneVolume = std::numeric_limits<float>::max();
|
||||
_tree->recurseTreeWithOperation(renderOperation, &args);
|
||||
const ZoneEntityItem* bestZone = NULL;
|
||||
|
||||
if (_currentZones.empty()) {
|
||||
// if we're not in any current zone, then we can completely erase our zoneHistory
|
||||
_zoneHistory.clear();
|
||||
} else {
|
||||
// we're in some zone... check to see if we've changed zones..
|
||||
QSet<EntityItemID> newZones = _currentZones - _lastZones;
|
||||
|
||||
if (!newZones.empty()) {
|
||||
// we just entered a new zone, so we want to make a shift
|
||||
EntityItemID theNewZone = *(newZones.begin()); // random we don't care, if it's one, then this works.
|
||||
_zoneHistory << _currentZone; // remember the single zone we used to be in.
|
||||
_currentZone = theNewZone; // change to our new zone
|
||||
|
||||
// do something to remove any item of _zoneHistory that is not in _currentZones
|
||||
QStack<EntityItemID> newHistory;
|
||||
QStack<EntityItemID>::iterator i = _zoneHistory.begin();
|
||||
while(i != _zoneHistory.end()) {
|
||||
EntityItemID zoneID = *i;
|
||||
if (_currentZones.contains(zoneID)) {
|
||||
newHistory << zoneID;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
_zoneHistory = newHistory;
|
||||
bestZone = dynamic_cast<const ZoneEntityItem*>(
|
||||
static_cast<EntityTree*>(_tree)->findEntityByEntityItemID(_currentZone));
|
||||
} else {
|
||||
|
||||
if (_currentZones.contains(_currentZone)) {
|
||||
// No change in zone, keep the current zone
|
||||
bestZone = dynamic_cast<const ZoneEntityItem*>(
|
||||
static_cast<EntityTree*>(_tree)->findEntityByEntityItemID(_currentZone));
|
||||
} else {
|
||||
if (!_zoneHistory.empty()) {
|
||||
_currentZone = _zoneHistory.pop();
|
||||
bestZone = dynamic_cast<const ZoneEntityItem*>(
|
||||
static_cast<EntityTree*>(_tree)->findEntityByEntityItemID(_currentZone));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<SceneScriptingInterface> scene = DependencyManager::get<SceneScriptingInterface>();
|
||||
|
||||
if (bestZone) {
|
||||
if (_bestZone) {
|
||||
if (!_hasPreviousZone) {
|
||||
_previousKeyLightColor = scene->getKeyLightColor();
|
||||
_previousKeyLightIntensity = scene->getKeyLightIntensity();
|
||||
|
@ -470,18 +417,16 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::R
|
|||
_previousStageDay = scene->getStageYearTime();
|
||||
_hasPreviousZone = true;
|
||||
}
|
||||
scene->setKeyLightColor(bestZone->getKeyLightColorVec3());
|
||||
scene->setKeyLightIntensity(bestZone->getKeyLightIntensity());
|
||||
scene->setKeyLightAmbientIntensity(bestZone->getKeyLightAmbientIntensity());
|
||||
scene->setKeyLightDirection(bestZone->getKeyLightDirection());
|
||||
scene->setStageSunModelEnable(bestZone->getStageSunModelEnabled());
|
||||
scene->setStageLocation(bestZone->getStageLongitude(), bestZone->getStageLatitude(),
|
||||
bestZone->getStageAltitude());
|
||||
scene->setStageDayTime(bestZone->getStageHour());
|
||||
scene->setStageYearTime(bestZone->getStageDay());
|
||||
|
||||
scene->setKeyLightColor(_bestZone->getKeyLightColorVec3());
|
||||
scene->setKeyLightIntensity(_bestZone->getKeyLightIntensity());
|
||||
scene->setKeyLightAmbientIntensity(_bestZone->getKeyLightAmbientIntensity());
|
||||
scene->setKeyLightDirection(_bestZone->getKeyLightDirection());
|
||||
scene->setStageSunModelEnable(_bestZone->getStageSunModelEnabled());
|
||||
scene->setStageLocation(_bestZone->getStageLongitude(), _bestZone->getStageLatitude(),
|
||||
_bestZone->getStageAltitude());
|
||||
scene->setStageDayTime(_bestZone->getStageHour());
|
||||
scene->setStageYearTime(_bestZone->getStageDay());
|
||||
} else {
|
||||
_currentZone = EntityItemID(); // clear out current zone
|
||||
if (_hasPreviousZone) {
|
||||
scene->setKeyLightColor(_previousKeyLightColor);
|
||||
scene->setKeyLightIntensity(_previousKeyLightIntensity);
|
||||
|
@ -699,7 +644,23 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
// like other entity types. So we will skip the normal rendering tests
|
||||
if (entityItem->getType() == EntityTypes::Zone) {
|
||||
if (entityItem->contains(args->_viewFrustum->getPosition())) {
|
||||
_currentZones << entityItem->getEntityItemID();
|
||||
float entityVolumeEstimate = entityItem->getVolumeEstimate();
|
||||
if (entityVolumeEstimate < _bestZoneVolume) {
|
||||
_bestZoneVolume = entityVolumeEstimate;
|
||||
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem);
|
||||
} else if (entityVolumeEstimate == _bestZoneVolume) {
|
||||
if (!_bestZone) {
|
||||
_bestZoneVolume = entityVolumeEstimate;
|
||||
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem);
|
||||
} else {
|
||||
// in the case of the volume being equal, we will use the
|
||||
// EntityItemID to deterministically pick one entity over the other
|
||||
if (entityItem->getEntityItemID() < _bestZone->getEntityItemID()) {
|
||||
_bestZoneVolume = entityVolumeEstimate;
|
||||
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// render entityItem
|
||||
|
|
|
@ -167,12 +167,9 @@ private:
|
|||
|
||||
QMultiMap<QUrl, EntityItemID> _waitingOnPreload;
|
||||
|
||||
QSet<EntityItemID> _lastZones;
|
||||
QSet<EntityItemID> _currentZones;
|
||||
QStack<EntityItemID> _zoneHistory;
|
||||
EntityItemID _currentZone;
|
||||
|
||||
bool _hasPreviousZone = false;
|
||||
const ZoneEntityItem* _bestZone;
|
||||
float _bestZoneVolume;
|
||||
|
||||
glm::vec3 _previousKeyLightColor;
|
||||
float _previousKeyLightIntensity;
|
||||
|
|
|
@ -257,6 +257,7 @@ public:
|
|||
|
||||
virtual bool isReadyToComputeShape() { return true; }
|
||||
virtual void computeShapeInfo(ShapeInfo& info);
|
||||
virtual float getVolumeEstimate() const { return _dimensions.x * _dimensions.y * _dimensions.z; }
|
||||
|
||||
/// return preferred shape type (actual physical shape may differ)
|
||||
virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; }
|
||||
|
|
Loading…
Reference in a new issue