void * getDirectedEdge(Vector3 const & e0, Vector3 const & e1) const { typedef std::pair<EdgeMap::const_iterator, EdgeMap::const_iterator> IteratorRange; Long3Pair base_key(toGrid(e0), toGrid(e1)); // Every edge within welding distance of the given edge must be inside a neighbor of the grid cell containing the edge for (int dx0 = -1; dx0 <= 1; ++dx0) for (int dy0 = -1; dy0 <= 1; ++dy0) for (int dz0 = -1; dz0 <= 1; ++dz0) for (int dx1 = -1; dx1 <= 1; ++dx1) for (int dy1 = -1; dy1 <= 1; ++dy1) for (int dz1 = -1; dz1 <= 1; ++dz1) { Long3Pair key(Long3(base_key.first.x + dx0, base_key.first.y + dy0, base_key.first.z + dz0), Long3(base_key.second.x + dx1, base_key.second.y + dy1, base_key.second.z + dz1)); IteratorRange nbrs = edge_map.equal_range(key); for (EdgeMap::const_iterator ni = nbrs.first; ni != nbrs.second; ++ni) { if ((ni->second.e0 - e0).squaredLength() <= squared_weld_radius && (ni->second.e1 - e1).squaredLength() <= squared_weld_radius) return ni->second.edge; } } return NULL; }
static void * _list_find_name(list *l, char *name) { node *n; if (l && !l->ht && list_length(l) > HASH_MIN_SIZE && l->sa) { l->ht = hash_new(l->sa, list_length(l), (fkeyvalue)&base_key); for (n = l->h; n; n = n->next ) { sql_base *b = n->data; int key = base_key(b); hash_add(l->ht, key, b); } } if (l && l->ht) { int key = hash_key(name); sql_hash_e *he = l->ht->buckets[key&(l->ht->size-1)]; for (; he; he = he->chain) { sql_base *b = he->value; if (b->name && strcmp(b->name, name) == 0) return b; } return NULL; } if (l) for (n = l->h; n; n = n->next) { sql_base *b = n->data; /* check if names match */ if (name[0] == b->name[0] && strcmp(name, b->name) == 0) { return b; } } return NULL; }
//////////////////////////////////////////////////////////////////////////////// // static void LLPanelMediaSettingsPermissions::initValues( void* userdata, const LLSD& media_settings , bool editable) { LLPanelMediaSettingsPermissions *self =(LLPanelMediaSettingsPermissions *)userdata; std::string base_key( "" ); std::string tentative_key( "" ); struct { std::string key_name; LLUICtrl* ctrl_ptr; std::string ctrl_type; } data_set [] = { { LLMediaEntry::CONTROLS_KEY, self->mControls, "LLComboBox" }, { LLPanelContents::PERMS_OWNER_INTERACT_KEY, self->mPermsOwnerInteract, "LLCheckBoxCtrl" }, { LLPanelContents::PERMS_OWNER_CONTROL_KEY, self->mPermsOwnerControl, "LLCheckBoxCtrl" }, { LLPanelContents::PERMS_GROUP_INTERACT_KEY, self->mPermsGroupInteract, "LLCheckBoxCtrl" }, { LLPanelContents::PERMS_GROUP_CONTROL_KEY, self->mPermsGroupControl, "LLCheckBoxCtrl" }, { LLPanelContents::PERMS_ANYONE_INTERACT_KEY, self->mPermsWorldInteract, "LLCheckBoxCtrl" }, { LLPanelContents::PERMS_ANYONE_CONTROL_KEY, self->mPermsWorldControl, "LLCheckBoxCtrl" }, { "", NULL , "" } }; for( int i = 0; data_set[ i ].key_name.length() > 0; ++i ) { base_key = std::string( data_set[ i ].key_name ); tentative_key = base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ); // TODO: CP - I bet there is a better way to do this using Boost if ( media_settings[ base_key ].isDefined() ) { if ( data_set[ i ].ctrl_type == "LLCheckBoxCtrl" ) { // Most recent change to the "sense" of these checkboxes // means the value in the checkbox matches that on the server static_cast< LLCheckBoxCtrl* >( data_set[ i ].ctrl_ptr )-> setValue( media_settings[ base_key ].asBoolean() ); } else if ( data_set[ i ].ctrl_type == "LLComboBox" ) static_cast< LLComboBox* >( data_set[ i ].ctrl_ptr )-> setCurrentByIndex( media_settings[ base_key ].asInteger() ); data_set[ i ].ctrl_ptr->setEnabled(editable); data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() ); }; }; // *NOTE: If any of a particular flavor is tentative, we have to disable // them all because of an architectural issue: namely that we represent // these as a bit field, and we can't selectively apply only one bit to all selected // faces if they don't match. Also see the *NOTE below. if ( self->mPermsOwnerInteract->getTentative() || self->mPermsGroupInteract->getTentative() || self->mPermsWorldInteract->getTentative()) { self->mPermsOwnerInteract->setEnabled(false); self->mPermsGroupInteract->setEnabled(false); self->mPermsWorldInteract->setEnabled(false); } if ( self->mPermsOwnerControl->getTentative() || self->mPermsGroupControl->getTentative() || self->mPermsWorldControl->getTentative()) { self->mPermsOwnerControl->setEnabled(false); self->mPermsGroupControl->setEnabled(false); self->mPermsWorldControl->setEnabled(false); } self->getChild< LLTextBox >("controls_label")->setEnabled(editable); self->getChild< LLTextBox >("owner_label")->setEnabled(editable); self->getChild< LLTextBox >("group_label")->setEnabled(editable); self->getChild< LLNameBox >("perms_group_name")->setEnabled(editable); self->getChild< LLTextBox >("anyone_label")->setEnabled(editable); }
//////////////////////////////////////////////////////////////////////////////// // static void LLPanelMediaSettingsGeneral::initValues( void* userdata, const LLSD& _media_settings, bool editable) { LLPanelMediaSettingsGeneral *self =(LLPanelMediaSettingsGeneral *)userdata; self->mMediaEditable = editable; LLSD media_settings = _media_settings; if ( LLPanelMediaSettingsGeneral::isMultiple() ) { // *HACK: "edit" the incoming media_settings media_settings[LLMediaEntry::CURRENT_URL_KEY] = LLTrans::getString("Multiple Media"); media_settings[LLMediaEntry::HOME_URL_KEY] = LLTrans::getString("Multiple Media"); } std::string base_key( "" ); std::string tentative_key( "" ); struct { std::string key_name; LLUICtrl* ctrl_ptr; std::string ctrl_type; } data_set [] = { { LLMediaEntry::AUTO_LOOP_KEY, self->mAutoLoop, "LLCheckBoxCtrl" }, { LLMediaEntry::AUTO_PLAY_KEY, self->mAutoPlay, "LLCheckBoxCtrl" }, { LLMediaEntry::AUTO_SCALE_KEY, self->mAutoScale, "LLCheckBoxCtrl" }, { LLMediaEntry::AUTO_ZOOM_KEY, self->mAutoZoom, "LLCheckBoxCtrl" }, { LLMediaEntry::CURRENT_URL_KEY, self->mCurrentURL, "LLTextBox" }, { LLMediaEntry::HEIGHT_PIXELS_KEY, self->mHeightPixels, "LLSpinCtrl" }, { LLMediaEntry::HOME_URL_KEY, self->mHomeURL, "LLLineEditor" }, { LLMediaEntry::FIRST_CLICK_INTERACT_KEY, self->mFirstClick, "LLCheckBoxCtrl" }, { LLMediaEntry::WIDTH_PIXELS_KEY, self->mWidthPixels, "LLSpinCtrl" }, { "", NULL , "" } }; for( int i = 0; data_set[ i ].key_name.length() > 0; ++i ) { base_key = std::string( data_set[ i ].key_name ); tentative_key = base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ); // TODO: CP - I bet there is a better way to do this using Boost if ( media_settings[ base_key ].isDefined() ) { if ( data_set[ i ].ctrl_type == "LLLineEditor" ) { static_cast< LLLineEditor* >( data_set[ i ].ctrl_ptr )-> setText( media_settings[ base_key ].asString() ); } else if ( data_set[ i ].ctrl_type == "LLCheckBoxCtrl" ) static_cast< LLCheckBoxCtrl* >( data_set[ i ].ctrl_ptr )-> setValue( media_settings[ base_key ].asBoolean() ); else if ( data_set[ i ].ctrl_type == "LLComboBox" ) static_cast< LLComboBox* >( data_set[ i ].ctrl_ptr )-> setCurrentByIndex( media_settings[ base_key ].asInteger() ); else if ( data_set[ i ].ctrl_type == "LLSpinCtrl" ) static_cast< LLSpinCtrl* >( data_set[ i ].ctrl_ptr )-> setValue( media_settings[ base_key ].asInteger() ); data_set[ i ].ctrl_ptr->setEnabled(self->mMediaEditable); data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() ); }; }; // interrogates controls and updates widgets as required self->updateMediaPreview(); }
//////////////////////////////////////////////////////////////////////////////// // static void LLPanelMediaSettingsSecurity::initValues( void* userdata, const LLSD& media_settings , bool editable) { LLPanelMediaSettingsSecurity *self =(LLPanelMediaSettingsSecurity *)userdata; std::string base_key( "" ); std::string tentative_key( "" ); struct { std::string key_name; LLUICtrl* ctrl_ptr; std::string ctrl_type; } data_set [] = { { LLMediaEntry::WHITELIST_ENABLE_KEY, self->mEnableWhiteList, "LLCheckBoxCtrl" }, { LLMediaEntry::WHITELIST_KEY, self->mWhiteListList, "LLScrollListCtrl" }, { "", NULL , "" } }; for( int i = 0; data_set[ i ].key_name.length() > 0; ++i ) { base_key = std::string( data_set[ i ].key_name ); tentative_key = base_key + std::string( LLPanelContents::TENTATIVE_SUFFIX ); bool enabled_overridden = false; // TODO: CP - I bet there is a better way to do this using Boost if ( media_settings[ base_key ].isDefined() ) { if ( data_set[ i ].ctrl_type == "LLCheckBoxCtrl" ) { static_cast< LLCheckBoxCtrl* >( data_set[ i ].ctrl_ptr )-> setValue( media_settings[ base_key ].asBoolean() ); } else if ( data_set[ i ].ctrl_type == "LLScrollListCtrl" ) { // get control LLScrollListCtrl* list = static_cast< LLScrollListCtrl* >( data_set[ i ].ctrl_ptr ); list->deleteAllItems(); // points to list of white list URLs LLSD url_list = media_settings[ base_key ]; // better be the whitelist llassert(data_set[ i ].ctrl_ptr == self->mWhiteListList); // If tentative, don't add entries if (media_settings[ tentative_key ].asBoolean()) { self->mWhiteListList->setEnabled(false); enabled_overridden = true; } else { // iterate over them and add to scroll list LLSD::array_iterator iter = url_list.beginArray(); while( iter != url_list.endArray() ) { std::string entry = *iter; self->addWhiteListEntry( entry ); ++iter; } } }; if ( ! enabled_overridden) data_set[ i ].ctrl_ptr->setEnabled(editable); data_set[ i ].ctrl_ptr->setTentative( media_settings[ tentative_key ].asBoolean() ); }; }; // initial update - hides/shows status messages etc. self->updateWhitelistEnableStatus(); }