Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 07 Apr 2000
Offline Last Active Aug 26 2015 04:47 PM

Posts I've Made

In Topic: [Qt 5] Moving Rows For Scene Tree (QAbstractItemModel)

13 August 2015 - 12:29 PM

Found this post while doing something similar for a scenegraph editor, hopefully its not too late to add more to it.



I looked into why this was, and it was due to my dropAction being set to InternalMove for my QTreeView. I thought InternalMove was what I needed, but it looks like DragDrop, does the job. The dangling pointer issue is resolved since my SceneModel no-longer removes nodes unexpectedly. My QTreeView's drag and drop performance also seems to work more fluidly. I used to have to select my node in a sweet spot to get it to work. I can also drag nodes into my the top-level hierarchy.



Actually that does not seem to be entirely accurate, I think removeRows should remove (delete scene nodes), such that you can use it for that specific purpose, say in a context menu or when pressing the delete key while a node is selected. What I found is that you should enable the DragDropOverrideMode on the view for it not to call remove on the original indices, DragDrop vs InternalMove seems not to make a difference to me.


Either way, the design seems to be missing something, models deal almost exclusively with QModelIndex objects, with row,column and internalPointer being the most important aspects of them, but then when drag and drop comes into the picture, you have to deal with mime types, with no alternate option to just have a "drop" method for indices or an index list. Furthermore, the information encoded in the default mime data is row, column and a map with what the data method returns for each role, no internalPointer which is most likely what you really need in this situation.


Here is a partial solution that overrides QTreeView::dropEvent in order to access the selected items, but I rather not have to create a new class that inherits from QTreeView just for that, so I am looking into options, so far, I guess the least intrusive option would be overriding QAbstractItemModel::itemData to include a UserRole with the item's internalPointer so I dont have to override QAbstractItemModel::mimeData which would be a different mess.


Either way you definitely need to override QAbstractItemModel::dropMimeData, the default implementation calls insertRows, and tries to fill the inserted rows with setData/setItemData, which is probably not what you or I want since my insertRows implementation calls new Node and we don't want a new node, we want the already existing one moved. So a call to moveRows would be much more appropriate, but you need to rebuild the source indexes from the mime data.


In Topic: CMake or Custom ?

08 April 2015 - 08:05 PM

I like CMake, its not perfect, but I wouldn't want to keep 3 or more build systems in sync for multi platform development, sure you have to change compiler flags from Linux to Windows and a lot more, but at least you do it in just one place. The fact that a lot of open source libraries use it also makes it easier to add them to your own project and build them yourself in case you like that kind of thing.


But if you're targeting Windows with VS and nothing more, I see no problem in just commiting your solution and project files onto your versioning system.

Custom build systems may take time to learn/understand to use for newcomers into your project, chances are, they may already know CMake.

In Topic: Wedding Celebration!, with free 3d envionment pack for all and discount o...

21 May 2014 - 04:11 PM

Congratulations! and Thanks! biggrin.png

In Topic: Implementing an Entity Component System in C++

27 February 2014 - 04:03 PM

I am sort of late to this discussion but I am looking on how to implement the pattern myself,


Ok thanks for your answers.


I have another trouble:

  • My game has maps
  • Maps are made of cells
  • Cells have a position, an ID and a texture.

What should be the components, what should be the entities?


I'm pretty sure Map should be an entity, but then:

  • Cell can't be an entity (otherwise I can't use it in my Map entity)
  • Cell can't be a component since it uses other components (Position, ID and Texture).


And the same problem goes for a lot of things. Can one use component in other components or did I get it all wrong?


From what I've gathered I would say neither of those are entities, they all should be part of a map resource, referenced by a map component that is updated by a map system.


To elaborate, your map may be a XML document with cell or tile elements themselves with position (relative to the origin), id and texture (itself a reference to an image, shader and/or material) attributes.

You write some code to convert the XML into a runtime resource object, which is then referenced by a map component, the component is the "instantiation" of your resource, and it will then contain information specific for that instance of the resource, for example position if your map may coexist with multiple maps snapped together.


Later on, in your game loop you may have a map system which updates any variables in your map component, and a rendering system may render it later, or a collision system may query the component which itself would query the resource for collision information, etc.

In Topic: Best way to get 2D overlays or images on screen (for a GUI).

06 June 2013 - 07:05 AM

I see, immediate mode, there is no reason why my GUI won't work with that, but since is no longer on core profile, I decided to drop it. but you're right, the amount of vertex calls for a single quad are too few in comparison to a full mesh that immediate mode shouldn't have that much of an impact in this situation.


In fact you can render your whole gui as 3d mesh (consisting of multilayered quads in front of a orthogonal camera). This way you could utilize some interesting effects, e.g. dynamic lighting of the gui, where the cursor is the light source, or automatic highlighting/bloom outlines of selected elements, gui shadows etc. This is not for pure functional guis, but it is really nice to pimp your gui visuals smile.png


I hadn't though much about that, It is nice, and you gave me a reason to expose shaders to the user, its all pimping of the UI as you said though, what I meant was that you never see any shaders for the basic operations, for example doing the bulk of the drawing on the fragment shader rather than just effects, but I guess its not really practical, and the way to do it is still the same as it was before the dynamic shader pipeline.


Thanks for your help! :)