Editing Blender Source Code

Hello! I’d like to know, how to edit an specific thing on blender source code. I’d like to change the “Clip End” limit for more than 1000.


How can I do that? Thanks! :slight_smile:

You’re not the first person to request that the clipping limit be changed.

Now, the way you phrased your question is interesting. :slight_smile:

You either :

a) - have setup a complete build environment
- have moderate to advanced C programming skills
- … but haven’t located the source file(s) / functions to modify


b) (More likely … but I apologize if I’m wrong)

- You have no idea about the enormous task that is invovled with such a "simple" change (especially if you haven't modified any of the Blender source code before, and doubly so if you haven't worked with a gigantic project like this).   (That modifciation may / may not indeed be enormous even for someone who's intimately familar with the source code and architecture of the program)

In either case I don’t know what would be involved to make such a change, but I have a pretty good idea, that it’s not just a matter of allowing a number bigger than 1,000 to be input in that dialog box :smiley:

Sorry for the (mostly) useless information in this post, but I couldn’t resist :slight_smile:


A quick estimate I think would be a minimum of two code changes. One to the gui, and one to the code that actually does the work.

I’ll now have a look to see what actual changes you would need to make.


My earlier estimate might have been wrong…

Ok, from the CVS as of Friday 9 June 2006 21:44…

In blender/source/blender/src/drawview.c, line 2322, in function view3d_panel_properties

uiDefButF(block, NUM, REDRAWVIEW3D, "Clip End:",    10, 86, 140, 19, &vd-&gt;far, 1.0, <b>1000</b>.0*vd-&gt;grid, 100, 0, "Set the end of the range in which 3D objects are displayed (perspective view)");

change the bit in bold to whatever upper limit you want

I’ve tried this on my own build. It seems to work ok as far as I’ve been able to tell.


Well, I’m taking a wild guess that maybe the clipping distance affects / or is affected by a lot of other code / design decisions.

If it’s as simple as you think, that would be great, but I’m sceptical.


Hmm, interesting, if it really is that simple, wonder why it is set so “low” ?

Now, can you find the camer-clipping code too ? :smiley:

edit … While you’re at it, not much use increasing the view/camera clipping ranges, if you don’t also increase the allowable transform/object size ranges both in the tra(N)sorm dialog, and just where a “physical”/mouse g(rab) move is allowed to position an object … is that “automatically handled” when you increased the clipping range ? … I’ll try the same mod on my system to see.

Did you crank the clipping to max, and then try to drag an object to the limits.



What kind of “code spelunking” tools are you using?

Do you have RedHat Source Navigator?


Yeah, I wondered why setting that would be just a few character job. I would have expected that some difficult things needed to be changed. Maybe reasons why this has been set so low is that:
a) in real world units, it is quite rare for you to need things in such a large scale
b) navigating around can be difficult
c) I remember hearing about some transform problems when quite far out, but I’m not sure what the nature of those are.

Usually this doesn’t really affect me, as I rarely work on anything that would need to have a upper clipping limit close to the limit, so I might not be testing this in the right way.


I started to do an “actual size” planet earth, zooming in to the smallest possible increment, and quickly ran into the clipping limit. I’ll play with your mod and see what’s possible.

I read another post, where someone was trying to model the solar system ,and ran into the clipping issue as well.


I can’t remember who pointed it out, but the built-in windows search does actually do quite a good job (try typing in a variable you’re not sure of where it is defined, searching for that phrase/word in files, and restrict it to only the directory where you have blender sources).

Another thing I do is, once I have opened a file for editing, I get my editor to list the functions that are declared in the file. That way, I can quickly get to the thing I’m looking for.

These days I usually use Notepad++, but in the past I used to use JEdit. JEdit was fine (and looked nicer to the eye), but what put me off was the fact that it was a java app, and java apps take ages to load which gives the feeling that the app must be slow as well.

Oh, by the way, read through the developer tuts and so forth at the wiki and the main blender site. Every time you re-read them, you usually will pick up something, especially after having a good look at the source yourself: finding something you want to work on, guessing where you might find the code, finding some more code, etc.


I read on the other thread you have mingw environment on windows set up.

can you please post what exactly is needed (do you use codeblocks with mingw by any chance?). I have custom builds on linux, but need some for windows.

Haven’t heard of Notepad++, I’ll take a look, is it specficically for programming?

Source-navigator is really nice, another useful tool is Cscope.

With source-navigator you can highlight a function or variable in the code, then CTRL-SH-D to go to the definition or CTRL-SH-I for the implemenation, sort of like “statically-single-stepping” the code.

Yes, I started with the constraints tutorial, and have looked through the other stuff, another good resource, that I mentioned before, is the CVS commit logs archive, have you looked through those? …Good for actual examples of what code has been changed/fixed for specific problems.


tedi: go to the blender wiki, and find the tutorial for getting blender to compile on windows with mingw and scons. Just remember to follow all the instructions and make sure you have all the requried files and that all blender sources are up to date. If you’re willing to wait for a long download, you could use cygwin and make, which should be simple if you have linux experience.

mstram: I’ve been reading the cvs logs for about a year now, ever since orange started now that I think about it. It’s part of my daily/near-daily web ‘rounds’.


thanks - I was wondering if there’s anybody knowing how to do it with the codeblocks-mingw - what’s needed for that.

tedi: I’d guess you’d need to set up the build system for that yourself. Use the SConscript and Makefile files in the directories as a base. The msvc project files might be more like what you’re looking for, but I cannot say as I haven’t used codeblocks before.


If i’m correct, as you increase the clip limit, you reduce the resolution on the z axis, so you might get odd looking things if you have planes that are too close.

Yeah, that’s what happens:


You can change the clipping values if you change the grid spacing option. So if spacing is 1 then min clip can be 0.1. Set spacing to 0.1 and the minimum clip becomes 0.01. But it lowers the max clip. So, in order to increase the max clip, you can increase the spacing at the expense of small detail. I don’t know if it’s a performance thing or what but it’s a pain.

it’s a matter of zbuffer depth. I bet a 64bit build of blender would allow better performance in this field.

No, it wouldn’t.
IEEE 754: Floating Point Single-Precision doesn’t change no matter what CPU you’re using.


Maybe I’m wrong, but why the ClipEnd has a relationship with the grid (like in 1000.0*vd->grid)

Don’t is better if the code is:

uiDefButF(block, NUM, REDRAWVIEW3D, "Clip End:",    10, 86, 140, 19, &vd-&gt;far, 1.0, <b>1000000.0</b>, 100, 0, "Set the end of the range in which 3D objects are displayed (perspective view)");

Dalai Felinto
Rio de Janeiro - Brasil

sorry the english :rolleyes: