Jump to content
The Dark Mod Forums

Draggable Light Center


Recommended Posts

My first impression on this topic: this seems to be a hard nut for me.

 

I spent the last 4 hours reading code and I'm still uncertain where to start... I think I understood how the clicks are monitored and passed on to the according observers, but I have no idea where the actual connections are being established (I lost the trace somewhere in this jungle and I'm too tired for today). What I found out is, that the current entities (including lights) don't seem to support for the eComponent selection modes, so this needs to be implemented. I wonder if this kind of overlaps with the future task of projected lights, as their vertices have to be draggable as well. There are also some fragments of code that were introduced with projected lights in mind, but they are commented out and not finished as it seems.

 

I'll look further into this, but this maybe too much for me, but I'll try of course. :)

Link to comment
Share on other sites

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

If you do decide to give up, I'll take the task back and have a look in a week or two. But I don't have any more insight into the codebase than you do. :)

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Ok, I'll let you know, if this is too much for me. At least I should be able to drop some comments between the lines - it's amazing to find 1 commented line for 3000 uncommented ones. How many people were writing on the base GTKRadiant application?

Link to comment
Share on other sites

I don't know, but I suspect there was mainly one person. Who kept all the details of how it worked in his head...

 

I think it might be a good idea to start adding comments ourselves when we figure out how various pieces of the system work. It would save us having to re-familiarize ourselves with it whenever we need to touch that part of the code again, and it would also enable other people to take up the work in case one of us drops off the face of the planet for whatever reason.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

This one-man-show stuff reminds me a bit of the Ion Storm Guy who coded this uber-leet flesh engine all by himself. On the one side it's pretty impressive for me, as he must have been skilled at coding, but on the other hand it was foolish to believe (from both Ion Storm and that guy himself) that one man alone can code an engine in such a short time without turning it into one huge hack.

 

But back to the selection stuff: I re-read some of the code in selection.cpp and it's getting somewhat more transparent by the time (but there is still some way to go for me). It's hard to disentangle and overview all those classes if everything is written into one cpp-file that's weighing several thousand lines. Briefly I thought about separating some of these classes in files and putting them in subdirectories, but I'm afraid that cross-porting features from GTKRadiant would get really hard for us afterwards.

Link to comment
Share on other sites

Briefly I thought about separating some of these classes in files and putting them in subdirectories, but I'm afraid that cross-porting features from GTKRadiant would get really hard for us afterwards.

 

Don't worry about that, we are way ahead of GTKRadiant by now. If it helps to separate out the classes, by all means do so.

 

I agree about the commenting, it is quite atrocious. In many cases I have added my own comments and/or reformatted legacy functions which relate to code that I am implementing, just to make it easier when I come back and look at it later.

Link to comment
Share on other sites

Don't worry about that, we are way ahead of GTKRadiant by now. If it helps to separate out the classes, by all means do so.

 

Really! Are the focussing on something else, or are they so slow?

 

But I think this is a very good excerise in learning how important proper commenting is. Programmers always complain that it takes so much time to document the code, but this is not true. If you comment while you write the code, it takes almost no time away. Of course going back later and commenting really takers a lot of time, that's why I always write my comment right before I start typing the code. It also helps to think about it before you actually start.

Gerhard

Link to comment
Share on other sites

Don't worry about that, we are way ahead of GTKRadiant by now. If it helps to separate out the classes, by all means do so.

Ok, will do what I can. Aren't there several people on GTKRadiant itself? I first suspected that they may be faster than us because of more manpower. Or are they heading to different directions (like Wolfenstein-specific things)? Is id software still involved in GTKRadiant development?

Link to comment
Share on other sites

Really! Are the focussing on something else, or are they so slow?

 

Both. They have a different goal (support every game under the sun), and a slower development process due to the spaghetti-like code structure, which we are ripping out and replacing where necessary but they only make minor tweaks and add even more spaghetti.

 

In an ideal world I would be able to help them backport DarkRadiant improvements into the main codebase, but it would take so much time and effort to convince everybody that the design was better than what they already have, that it is unlikely anything would get done. I mean, SPoG actually LIKES all the impenetrable templates (he wrote most of them).

 

But I think this is a very good excerise in learning how important proper commenting is. Programmers always complain that it takes so much time to document the code, but this is not true. If you comment while you write the code, it takes almost no time away. Of course going back later and commenting really takers a lot of time, that's why I always write my comment right before I start typing the code. It also helps to think about it before you actually start.

 

That's exactly right. I generally write loads of comments, because I am not actually that good a coder and I have to write out what I am going to do otherwise I will get confused.

 

Aren't there several people on GTKRadiant itself? I first suspected that they may be faster than us because of more manpower. Or are they heading to different directions (like Wolfenstein-specific things)? Is id software still involved in GTKRadiant development?

 

Only recently they added a couple of extra committers (namespace and Shaderman) so development may pick up a bit. They are still hampered by the need to support all the different games however. I suspect eventually it will become too onerous to work this way, and they will have to split off into editors for different games.

Link to comment
Share on other sites

But I think this is a very good excerise in learning how important proper commenting is. Programmers always complain that it takes so much time to document the code, but this is not true. If you comment while you write the code, it takes almost no time away. Of course going back later and commenting really takers a lot of time, that's why I always write my comment right before I start typing the code. It also helps to think about it before you actually start.

I totally agree, altough I personally prefer paper and pencil to plan out my code, but of course this is a matter of taste :). I also use the time that it takes to compile my changes to comment the code. This worked quite well up to now, but it gets harder now as the compile times have reduced recently :P

Link to comment
Share on other sites

Yeah, I just went quickly over this changelog and it's mostly SPoG who worked on this piece it seems.

 

Many years ago (I was 15 I think) I considered it to be kind of uncool to write comments, as I thought: real programmers always know their code, but we all get wiser, don't we? My largest Pascal/Assembler pieces were about 10k lines of code (uncommented of course), which was not a problem as long as I constantly worked on it, but imagine what happened to my brain as I re-opened some of the files two years later. :D

Link to comment
Share on other sites

I generally write loads of comments, because I am not actually that good a coder and I have to write out what I am going to do otherwise I will get confused.

I don't think that's a sign of not being a good coder... I think it's normal. I do it as well. Coding requires so much concentration that we simply can't hold all the details in our heads at once; we have limited short-term memory capacity. So writing things down helps to keep everything together, since we can afford to temporarily forget the details of one part of it while we work on another part.

 

If people don't write things down at some point, then it means they probably don't have a very cohesive notion of how the program is going to be structured; so rather than carefully build a well-documented program with useful and reusable subsystems, people like this tend to just hack on the code repeatedly. After enough of these hacks, you end up with a giant mass of spaghetti. Hence GTKRadiant.

 

This doesn't mean that everything has to be done using "big design up front" (UML, etc.) - in fact, pure BDUF doesn't work very well anyway (and UML sux0rs teh big one ;)), because the stated requirements will always change during the process. It does mean that you need to think a bit before you launch into a big project (anything larger than a simple scripting task). Unfortunately, most programmers (myself included) go through a stage where they think they can just launch into coding and get things done faster without the initial planning. Most people outgrow this when they've worked on a few large projects. The GTKRadiant guy evidently hasn't.

 

This is not to disparage that kind of programming - those people can be great hackers (in the original, free-spirited information-sharing sense of the word, as opposed to "crackers") and some of them are geniuses. But they don't do software engineering very well.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

I'm really not surprised to hear that the code for GTKRadiant is a pile of Spaghetti. The editor has felt so much tighter and focussed since you guys started working your magic. :) I don't have a clue what goes on underneath the hood, but I can definitely see the difference in the app itself. I really hope that between the team and the beta mappers, we can help the coding team turn this into the best Thief oriented editor possible.

Link to comment
Share on other sites

  • 2 weeks later...

I was thinking about how to implement the draggable center while cleaning up some of the light code, and it occurs to me that a Doom 3 light is actually a group, which can have children (such as a model). I wonder if it would be possible to add the light center as a child object of the light, which would only be visible when the light was selected, but could be moved around just like any other object in Radiant.

 

I think DoomEdit might have done it this way, which is why you had to sometimes press TAB to manipulate either the light center or the child model.

Link to comment
Share on other sites

I was looking at the brush vertex code (which works in a similar way to what we want to achieve, and the way it did it was to inherit from a bunch of (pure abstract) classes like ComponentSelectionTestable etc., and implement the methods that those classes require. The info about which components are selected is kept on the parent object (BrushInstance in that case; Light in our case). You can get a fair amount of flexibility that way, since the class determines how things are selected, drawn, etc.

 

I didn't get as far as working out how you tell the selection system "I have components!" though.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

That sounds better. This might also open the door for projected lights with manipulatable direction and sizing vectors.

 

I wonder why it is BrushInstance that implements this, but Light rather than LightInstance.

Link to comment
Share on other sites

I wonder why it is BrushInstance that implements this, but Light rather than LightInstance.

Good point... I hadn't noticed that there was a LightInstance class, but there is - and it already has components! They're called "drag planes". According to a comment in the code (yes, a comment, try not to die of shock :rolleyes: ) they're for resizing lights using the mouse, but I can't figure out how to use them. Anyone know?

 

At any rate, this might make it a bit more straightforward to implement. :) I'll have a go now.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

I don't think DragPlanes will help you - that is the system that allows you to resize something by dragging outside it. We need something a lot more precise than selecting a bounding plane, we want to select a specific point.

 

There is a document in the md3model plugin folder than might shed some light on this, there is some system whereby the entity can ask Radiant for a "selection ray", and then determine for itself whether that ray intersects a specific part of the object.

Link to comment
Share on other sites

Oh, I know it's unrelated. Point is, it already has some of the infrastructure for selecting components in place, so I might be able to use that to add my own component. I'm still not entirely clear on how it all fits together, but I'm getting there.

 

I dunno about rays, but there is a SelectionTest class which the brush uses which looks potentially helpful.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Little update on this...

 

I can now select the light centre... sort of. It only works when I'm in vertex selection mode, and only when I'm also selecting brush vertices. And there's no way to deselect. Must be missing some code...

 

But in any case, the fact that it only works in vertex selection mode has made me realise that I've been doing this completely wrong the entire bloody time. The "selectable components" thing is really only meant for brushes. No wonder I've been having so much trouble - I've been trying to jam a light-shaped peg into a brush-shaped hole.

 

I'm going to revert back to SVN and see if your Doom3Group method looks workable.

 

Crispy can't come to the phone right now, as he's on a wild goose chase through the Spaghetti Marshes of SPoG. Please leave a message after the beep. *BEEP*

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Crispy can't come to the phone right now, as he's on a wild goose chase through the Spaghetti Marshes of SPoG. Please leave a message after the beep. *BEEP*

 

Heh, if you're looking for some amusement look at aabb_extend_by_aabb() in math/aabb.h. You are not mistaken, that really is a template parameter being used as a loop iterator.

 

EntityKeyValues is pretty good as well - a wrapper around a list of pairs which re-implements a map (but a lot slower because it has to search from the beginning).

Link to comment
Share on other sites

Heh, if you're looking for some amusement look at aabb_extend_by_aabb() in math/aabb.h. You are not mistaken, that really is a template parameter being used as a loop iterator.

I believe the traditional response to this kind of thing is OMGWTFBBQ. Or possibly "my eyes, the goggles they do nothing!"

 

Reminds me of that Monty Python song...

 

Wife: "Haven't you got anything without templating?"

Waitress: "Well, we've got a templated scene::Instance casting-template implemented with templated templates, that ain't got much templating in it."

Wife: "But I don't like templates!"

Man: "I love 'em! I'll have yours!"

Vikings: "Tem-plates tem-plates tem-plates tem-plates..."

 

(Don't get me wrong, templates are good, but in the same way cheese is good; if you have too much things start to, uh, grind to a halt.)

 

EntityKeyValues is pretty good as well - a wrapper around a list of pairs which re-implements a map (but a lot slower because it has to search from the beginning).

Ah yes - the old trick of ditching the STL because it's "too slow", and then reimplementing everything using linear searches instead of hash tables. It never goes out of fashion!

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 1 reply
    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
×
×
  • Create New...