Jump to content
The Dark Mod Forums

mohij

Member
  • Posts

    244
  • Joined

  • Last visited

Posts posted by mohij

  1. 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.

  2. 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?

  3. 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...

  4. 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...

  5. 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; 
    	 } 
     }

  6. 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.

  7. 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).

  8. 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*.

  9. 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...)

  10. 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.

  11. 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?

×
×
  • Create New...