List of questions concerning proper coding and defects ?

Hello to anyone who reads this.

I am interested in learning the Blender codesbase and helping out. Of course I first need to learn programming more thoroughly.

I am starting this thread to get an idea of what is considered both proper and defective coding for Blender. I am planning to ask a series of these types of questions regarding the Blender codebase as the questions arise. I guess I will just place each question within this thread.

For now I only have two simple questions, if anyone is interested in helping.

I don’t no the exact revision I have but I did a checkout around 04/01/12 from :

In the file interface_panel.c

@func static void check_panel_overlap(ARegion *ar, Panel *panel)

/*code snippet*/
   <b>if</b> (pa-&gt;paneltab==NULL && (pa-&gt;runtime_flag & PNL_ACTIVE)) {
      float safex= 0.2, safey= 0.2;
      <b>if</b> (pa-&gt;flag & PNL_CLOSEDX) safex= 0.05;
      <b>else if</b> (pa-&gt;flag & PNL_CLOSEDY) safey= 0.05;
      <b>else if</b> (panel-&gt;flag & PNL_CLOSEDX) safex= 0.05;
      <b>else if</b> (panel-&gt;flag & PNL_CLOSEDY) safey= 0.05;

Ok, these first questions below were stupid… I just now noticed the difference of

Well, I can’t delete this post so maybe I’ll just continue posting questions as I think of them.

Q1) Are any of the above else if statements redundant? (i.e. should they be deleted)

Q2) If they are not redundant, can you tell me why they are needed?


@WiseLyons, evidentially - only one of these flags may be set so seems reasonable to use 'else if’s here.

This is a fairly obscure area of code, unless you are trying to fix a bug or add a feature here, I think there are better areas to start.

Suggest to be more task oriented - try solve a problem - eg:
Then start with the big picture and study only the code you need.

Alternately you could say - “task oriented be damed! I want to understand this code - no matter what” - In that case I suggest…

  • look at the history of the file “svn blame -x -w somefile.c”, find the commit that changes these lines and read the commit log.
  • try change the code yourself and see what happens.
  • add prints in the code and see which ones run (a printf for each IF in this case would make sense.)
    … this is time consuming, but once you’re done you should be able to make fixes/changes/improvements to the code much more easily.

Hi ideasman42.

Thanks very much for your time and answer sir. I actually don’t know why I posted those two questions… I believe it’s because I’m not thinking clearly. But the problem was that originally(before posting) my brain only saw 4 " panel->flag ", but after posting I realized there were 2 " pa->flag " and 2 " panel->flag " bit comparison’s. And so this thread was/is currently unnecessary, I guess…

However, it is a pleasure and comfort to recieve advice from a well established Blender Dev. Thanks man!


triple times hooray for a new develloper who wants to get involved with the Blender code, apparently you already know about netiquette … unfortunately I can not give a more insightful reply than ideasman42 but still I (we) appreciate you being here …

you can disregard this post ad hoc