Jump to content
The Dark Mod Forums


  • Posts

  • Joined

  • Last visited

Everything posted by mohij

  1. Wait, I have already done it. I just do a last compile to see if it works. Edit: I uploaded the latest progress to: latestProgress.diff
  2. So shall I revert all my changes in respect to the nonconsting?
  3. After changing this Visitor::visitor from const to nonconst, a LOT of dependencies need to be changed too. At some point (after changing a lot of functions from const to non const) gcc spits this out radiant/brush/BrushVisit.h: In function 'const Functor& Scene_forEachSelectedBrush(const Functor&) [with Functor = BrushForEachFace]': radiant/brush/BrushVisit.h:162: instantiated from 'const Functor& Scene_ForEachSelectedBrush_ForEachFace(scene::Graph&, const Functor&) [with Functor = FaceSetShader]' radiant/brushmanip.cpp:385: instantiated from here radiant/brush/BrushVisit.h:25: error: no matching function for call to 'SelectionSystem::foreachSelected(BrushSelectedVisitor<BrushForEachFace>)' include/iselection.h:143: note: candidates are: virtual void SelectionSystem::foreachSelected(SelectionSystem::Visitor&) const But these functions seem to comply. I did a lot trial-and-error on the functions in those files but at some point gcc always spits out a similar message. I start to wonder if it's a good idea to make the Visitor::visit nonconst... If someone wants to take a look, I uploaded a diff: monsterClipDiff.diff Some hint what's wrong would be helpful.
  4. radiant/ui/ortho/OrthoContextMenu.cpp: In member function 'void ui::OrthoContextMenu::checkMonsterClip()': radiant/ui/ortho/OrthoContextMenu.cpp:154: error: no matching function for call to 'SelectionSystem::foreachSelected(ui::ModelFinder (&)())' include/iselection.h:143: note: candidates are: virtual void SelectionSystem::foreachSelected(const SelectionSystem::Visitor&) const radiant/ui/ortho/OrthoContextMenu.cpp:157: error: request for member 'modelList' in 'ui::visitor', which is of non-class type 'ui::ModelFinder ()()' radiant/ui/ortho/OrthoContextMenu.cpp:157: error: request for member 'onlyModels' in 'ui::visitor', which is of non-class type 'ui::ModelFinder ()()'I get this error message that says that my visitor is no class. typedef std::vector<scene::Path> InstanceList; class ModelFinder : public SelectionSystem::Visitor { InstanceList targetList; bool onlyModels; public: ModelFinder() : onlyModels(true) {} void visit(scene::Instance& instance) { Entity* entity = Node_getEntity(instance.path().top()); if (entity->isModel()) { targetList.push_back(instance.path()); } else { onlyModels = false; }}}; But this is obviously a class. For completeness here the lines that cause the error: ModelFinder visitor(); GlobalSelectionSystem().foreachSelected(visitor); I have really no idea what the reason is, as this is really just a normal class. Any ideas?
  5. I use the wiki actively all the time (otherwise I would by far haven't come as far as I have). According to your explanation the scenegraph is no real node structure with child/parent nodes, but a derivation structure with a base class and derived subclasses. Is that correct? You implemented that quite fast 8-| I hope the sync won't require many manual merges...
  6. I'd be gratefull if you do that, since I really don't entirely know the Scenegraph yet. Especially after you said how to recognize models. An Instance can be an entity? I thought an Instance was a path with rootnode, entity and primitives (nodes). Non-empty spawnarg name? in ientity.h: STRING_CONSTANT(Name, "Entity"); I obviously get some things wrong here...
  7. I hoped you would say that *happy* Okay, another question: Models are listed under the "func_static" entity. What key do I need to check for that?
  8. Yeah, that's what I tried for the last half hour.... grrrrr that stupid const function. Now I ended up keeping a bool* and an InstanceList* in the class and changing the outside objects....
  9. With that visitor class the "create monsterClip" button would work even with other stuff selected, but only operate on the models. Is that intended?
  10. I want the menu button "create MonsterClip" to work when one or more models are selected. So I want to check the SelectionList for non models and switch the button sensible/insensible. When called I'd like to create the monsterClip for every item in the SelectionList.
  11. How can I iterate the SelectionList? The SelectionList is a template (is there more than one?), and the iterator is templated to, so I don't know how to use the iterator. Same problem with a->name. Where is the actual instance of the SelectionList? for(iterator a = SelectionList.begin(), a != SelectionList.end(), a++) { // TODO: to be replaced by inheritance-based class detection if (!string_equal_nocase(a->name, "func_static")) { nonModel = true; break; } }
  12. But you have to set showOptions to false first, and if you set that one to false, you should already understand that the results in the returned structure are meaningless. I think I will now add the "add clipBrush" option to the right-click-menu.
  13. I think that's overtuned. When it's only about hiding the options entirely a nice ModelSelectorResult chooseModel(bool showOptions=true); should do the job cleaner.
  14. Should I grey out the options seperately (keeps them still ticked which could cause some confusion) or hide them altogether (prevents showing only some of the options)? Edit: greying them out seperately can make the function inverface quite bloated once more functions are added.
  15. As I said, the childBounds() returns the correct AABB (no idea what the difference is). In radiant/selection/algorithm/Primitives.cpp in createCMFromSelection() the ModelSelector is also used, but I have no idea where this function is actually used in DarkRadiant. Could you tell me where this feature (what ever it might be) hides? I think I will hide the "create bounding box" option when called from the ModelPropertyEditor.
  16. Woho, I got it to work. Even though I wrote another function that calls ConstructCuboid more directly than Scene_BrushResize_Selected. That function was to suspicious to me, since visually selecting a brush to operate on it seems wrong. And worldAABB returned the wrong AABB for small models. childBounds produces correct results. But I have no idea what the difference is, I just did some trial-and-error. Now I'm thinking if it would make sense to add a way to hide or gray out the option, since in some cases adding a bounding box doesn't make sense (eg. when changing the model).
  17. That function is not listed in the .h file and is called by Scene_BrushResize_Selected. If changing that is fine then ConstruchtCuboid is the best choice I guess.
  18. It seems that this first part of the code works now. But no brush is created and on drag it shows Warning: removed degenerate brush! I replaced the AABB in Scene_BrushResize_Selected with a manually constructed one and it still shows the same message. So I guess that Scene_BrushResize_Selected doesn't work. I think this function is not intended for this purpose, perhaps I find a better one. I'll take a look tomorrow *yawn*.
  19. Wait a moment, why did the model show up when it was never inserted into the tree? Edit: Now it shows: libs/instancelib.h:183 assertion failure: InstanceSet::insert - element already exists
  20. I sort-of understand it only a little bit better now, this IS complicated... ModelSelectorResult ms = ui::ModelSelector::chooseModel(); // If a model was selected, create the entity and set its model key if (!ms.model.empty()) { try { scene::INodePtr modelNode = Entity_createFromSelection(MODEL_CLASSNAME, self->_lastPoint); Node_getEntity(modelNode)->setKeyValue("model", ms.model); Node_getEntity(modelNode)->setKeyValue("skin", ms.skin); // If 'createClip' is ticked, create a clip Brush if (ms.createClip) { // get the model scene::Path brushPath(GlobalSceneGraph().root()); brushPath.push(GlobalMap().getWorldspawn()); brushPath.push(modelNode); scene::Instance& instance = findInstance(brushPath); // retrieve the AABB AABB brushAABB(instance.worldAABB()); scene::INodePtr brushNode(GlobalBrushCreator().createBrush()); Node_getTraversable(GlobalMap().findOrInsertWorldspawn())->insert(brushNode); Scene_BrushResize_Selected(GlobalSceneGraph(), brushAABB, "textures/common/monster_clip"); }This segfaults because findInstance finds nothing. Could it be that Scene_BrushResize_Selected only works on the Brush visually selected in the XY view? Then that function is totally misplaced there. (and that function seems not to use the first argument...)
  21. ModelSelectorResult ms = ui::ModelSelector::chooseModel(); // If a model was selected, create the entity and set its model key if (!ms.model.empty()) { try { scene::INodePtr node = Entity_createFromSelection(MODEL_CLASSNAME, self->_lastPoint); Node_getEntity(node)->setKeyValue("model", ms.model); Node_getEntity(node)->setKeyValue("skin", ms.skin); // If 'createClip' is ticked, create a clip Brush if (ms.createClip) { scene::INodePtr node(GlobalBrushCreator().createBrush()); Node_getTraversable(GlobalMap().findOrInsertWorldspawn())->insert(node); scene::Path brushpath(GlobalSceneGraph().root()); brushpath.push(GlobalMap().getWorldspawn()); brushpath.push(node); selectPath(brushpath, true); Scene_BrushResize_Selected(GlobalSceneGraph(), //AABB (Vector3(1,2,3),Vector3(1,1,1)), .localAABB(), "textures/common/monster_clip"); //AABB::createFromMinMax(mins, maxs), } I need to get the AABB of that model for Scene_BrushResize_Selected. btw. Is there an easier way to create a brush, I don't really understand what all those commands do, I just copied them from XYWnd.cpp.
  22. OrbWeaver: Your approach worked out very well, since it is backwards compatible (so I don't have to change all callers at once). One more question, how can I retrieve a model from a node? I guess with localAABB() I can then get it's AABB.
  23. After programming 5 hours or so I noticed that my approach on the "add bounding box" checkbox can't work out. The ModelSelector just returns a Model and a Skin name. Everything else has to be done by the caller. So a tick box "create bounding box" would have to be evaluated by the caller too. My approach was to change ModelSelector into a "normal" singleton class with a getInstance function. I also added another function that returned the state of the "create bounding box" checkbox. After changing the Ortho Menu to use the new interface and evaluate the new option I noticed that the Ortho Menu isn't the only one that uses the ModelSelector. Reimplementing the evaluation of the options everywhere the ModelSelector is used seems stupid, especially when even more options are added. Any ideas how to solve that in an elegant way?
  24. Hehe ;-) I meant something with 3d or 2d, like the clipper tool or something.
  25. I work since a week or so, so my time is limited. But I can surely try another task. If possible something in space would be interesting, but it's not that important.
  • Create New...