OpenGL draw.
(BTW: the previous commit also solves raytrace errors with negative scaled
objects...)
Further a cleanup of displaylist flags and object/base flags. The #define
ACTIVE is moved to filesel.c (only used here).
The GONNA_MOVE #define got a OB_ added in front.
switches (glMaterial) inbetween a glBegin and glEnd. Combined with a
switch of glShadeModel however, on recent Nvidia it caused faces not
to be drawn... dunno if this is official compliancy, but not too
complex just to correct.
Bug 1258: selecting objects with text drawing (axis, or as draw extra)
causes crashes in IBM cards. Has been tested & verified. A crash on
selecting Empty is often reported... so I just disabled drawing of
text when in selecting-draw mode.
Added comments in code to note it clearly.
In Mesh editmode, with option "draw faces", hiding 1 vertex of a quad
doesn't always result in not drawing the face. Only 3 out of 4 vertices
were tested.
(MVert,MFace,etc) off into DNA_meshdata_types.h, to isolate areas
of source that actually edit mesh *data* vs. areas that just edit
mesh object information.
of zr). This struct was never written to file and the new 'int based'
MFace can be used in it's place. Some removal of redundant code could
perhaps be done now (I didn't do any though, just "s/MFaceInt/MFace/").
--------------------------
Major speed up for armatures during times when you aren't
posing a figure.
Background: the calculation of poses generated by actions and the
calculation of displists were getting somewhat out of sync.
This was being remedied by 'clearing the constraint done flag'
of the pose channels and recalculating the displists every time
the 3d view was redrawn, making life slow and unpleasant.
Commenting out the code that was doing this, then reinserting
the 'clearing the constraint done flag' at the right times
made things a bit more perky.
- New lamp type added "Area". This uses the radiosity formula (Stoke) to
calculate the amount of energy which is received from a plane. Result
is very nice local light, which nicely spreads out.
- Area lamps have a 'gamma' option to control the light spread
- Area lamp builtin sizes: square, rect, cube & box. Only first 2 are
implemented. Set a type, and define area size
- Button area size won't affect the amount of energy. But scaling the lamp
in 3d window will do. This is to cover the case when you scale an entire
scene, the light then will remain identical
If you just want to change area lamp size, use buttons when you dont want
to make the scene too bright or too dark
- Since area lights realistically are sensitive for distance (quadratic), the
effect it has is quickly too much, or too less. For this the "Dist" value
in Lamp can be used. Set it at Dist=10 to have reasonable light on distance
10 Blender units (assumed you didnt scale lamp object).
- I tried square sized specularity, but this looked totally weird. Not
committed
- Plan is to extend area light with 3d dimensions, boxes and cubes.
- Note that area light is one-sided, towards negative Z. I need to design
a nice drawing method for it.
Area Shadow
- Since there are a lot of variables associated with soft shadow, they now
only are available for Area lights. Allowing spot & normal lamp to have
soft shadow is possible though, but will require a reorganisation of the
Lamp buttons. Is a point of research & feedback still.
- Apart from area size, you now can individually set amount of samples in
X and Y direction (for area lamp type 'Rect'). For box type area lamp,
this will become 3 dimensions
- Area shadows have four options:
"Clip circle" : only uses a circular shape of samples, gives smoother
results
"Dither" : use a 2x2 dither mask
"Jitter" : applys a pseudo-random offset to samples
"Umbra" : extra emphasis on area that's fully in shadow.
Raytrace speedup
- improved filling in faces in Octree. Large faces occupied too many nodes
- added a coherence check; rays fired sequentially that begin and end in
same octree nodes, and that don't intersect, are quickly rejected
- rendering shadow scenes benefits from this 20-40%. My statue test monkey
file now renders in 19 seconds (was 30).
Plus:
- adjusted specular max to 511, and made sure Blinn spec has again this
incredible small spec size
- for UI rounded theme: the color "button" displayed RGB color too dark
- fixed countall() function, to also include Subsurf totals
- removed setting the 'near' clipping for pressing dot-key numpad
- when you press the buttons-window icon for 'Shading Context' the context
automaticilly switches as with F5 hotkey
Please be warned that this is not a release... settings in files might not
work as it did, nor guaranteed to work when we do a release. :)
even for each redraw! Now its all smooth & fast again.
introduced new kernel API call: int is_basis_mball(ob), this provides a
quick check of the object is the actual basis for the displaylist and
polygonization.
colors. This because of the pretty weird (ab)use of load & make editmesh...
For each added undo step, the load_editmesh was fed with an empty mesh
to assign data to, without knowledge of what was in the original mesh.
That way UV and color data got lost.
Solved it in 2 steps:
1. removing the ->tface pointer from EditVlak, and make TFace a builtin
struct inside EditVlak. This didnt cost much extra mem, since it already
stored UV and color. This enabled some pretty cleanup in editmesh.c as
well, storing tface pointers was cumbersome.
2. for each undo step, it then generates always a tface and mcol block to
link to the undo Mesh.
Even when it wasn't in the actual Mesh, at exit editmode the original
Mesh is used as reference anyway, and undo-meshes are freed correctly.
The enormous commit is because I had to change the BLI_editVert.h file, and
found it was included in about every file unnecessary. I removed it there.
ALso found out that subsurf has code ready (unfinished) to make UV coords for
the displaylist in EditMode as well, nice to know for later...
Still one little problem: It draws the line even where there is not constraint target. Guess I'll have to wip a function to check for that if there isn't one already.
Note to Ton: You just need to add the color link to theme
- problem was in limiting the abuse of frontbuffer drawing as happended
a lot in 2.28 and older. the less the better...
- bug was not registering a curarea->win_swap=FRONT_OK, to indicate there
was only drawn in frontbuffer
- cleaned up calls further, and made sure it doesnt draw 1 vertex too many!
also means it works better with selecting in solid drawmode now, check!
- fixed constraint popup menu (used icons)
- moved 'full' and 'View3d props' and 'background' items in menu to bottom
Hope Matt wont kill me for it, but these were about the only useful
ones there... :)
- little fix in interface.c for menus...
- uses callback mechanism to tell main drawing routine what to do
- for that reason it doesn't use frontbuffer drawing anymore
and it shows up in all 3d windows as well
- it uses the same colors as for the grid axes (I tweaked it a bit,
this is based at themecolors, and also should work in different
background and grid color)
- I disabled drawing lines through every object or every vertex.
The current display method is clear and not distracting
- when in 'local' transform (double press X/Y/Z), it displays a nice
axis in the center of transform for vertices.
In object-mode, local transform differs per object, so constraint lines
and axes are drawn for each individually...
Also:
- fixed an old bug in rotate transform(). Using a constraint for
rotation (X, Y, Z) didn't work for multiple objects at all!
- transparent faces in editmode don't write in zbuffer anymore (prevents
drawing errors) but still read (so behind the subsurf faces for example)
- improved drawing 'handles' for subsurf editing
- going in editmode to Solid view, will draw extra wire always, including
transparent faces when set
- works in all combos... http://www.blender.org/docs/ton/subsurf.html
- fixed error; padplus/padminus didnt work in buttonswindow anymore
- improved buttonswin: when dragging window edge, the buttons dont
rescale, but stay same size
was caused because i only tested the new cool 'draw wire extra'. :)
- by default, in solid draw mode & editmode, it does a 'draw wire extra'
now, giving nice clean editmesh drawing.
- there's still a few quirks, i do a test now... this commit is to have
a good working blender in cvs. the whole drawing system is such chaos...
- in zbuffer mode, vertices will be blended 50% in... and when you increase
vertex size larger than 2 pixels, it will draw them smaller
- removed all 'wire extra' calls (there were dozens!) and replaced it with
simple call where it belongs.
This drawing mode is becoming nice & stable... maybe something to make
default on for new objects? Makes selecting quite easier...
- Subsurf: in editmode, with new 'Optimal' option set, the mesh itself
will not draw, but instead it draws 'handles' to the vertices. Looks
extremely clean!
- matched drawing of default grid-floor (persp) to ortho grid
- killed drawing vertices outside of main drawing loop, apart from the
routine that uses mouse-selecting. (tekenvertices_ext()). It was an old
optimize routine which became quite useless.
This is only usefull for rotate now, but the axis constraining code has a part that depended on this, so I commit this part first.
For coders:
void constline(float *center, float *dir, int col)
Draw an infinite line on the screen. col is the color argument. It must be cpack compatible
void project_short_infiniteline(float *vec, float *dir, short *adr1, short *adr2);
clips infinite line to screen border
- faceselect mode works again
- selecting vertices for lattices, surfaces and curves works again
- in previewrender sometimes a square was drawn, which was texture-crop
it was using some unsupported linewidth trick... I've been trying to
get the official glPolygonOffset to working, but my silly Mac doesnt
support it, it seems.
So! I thought of another trick, and that's just moving the window
matrix a little to the front. :)
- for those interested; the code for glPolygonOffset is still there,
commented out. (drawobject.c)
- btw: the drawobject.c routines are a TOTAL mess!
can be found under the 'SubSurf' button.
Optimal drawing only shows the subdivided original edges. Quite nice!
And; it's a load faster!
- to evaluate: do we want this in editmode too?
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
like: BIF_ThemeColor(TH_GRID); will be sufficient. Blender does the rest.
- fixed bug in CTRL-X (reload home file) with themes
- fixed bug in horizontal alignment of different height panels. Seems also
to solve the drawing error with constraints...
- currently only implemented for 3d window
- create as many themes you like, and name them
- default theme is not editable, and always will be defined at startup
(initTheme)
- saves in .B.blend
- themes for spaces can become local too, so you can set individual
3d windows at theme 'Maya' or so. (to be implemented)
- it uses alpha as well...!
API:
This doesnt use the old method with BFCOLORID blahblah. The API is copied
from OpenGL conventions (naming) as much as possible:
- void BIF_ThemeColor(ScrArea *sa, int colorid)
sets a color... id's are in BIF_resources.h (TH_GRID, TH_WIRE, etc)
- void BIF_ThemeColorShade(ScrArea *sa, int colorid, int offset)
sets a color with offset, no more weird COLORSHADE_LGREY stuff
- void BIF_GetThemeColor3fv(ScrArea *sa, int colorid, float *col)
like opengl, this gives you in *col the three rgb values
- void BIF_GetThemeColor4ubv(ScrArea *sa, int colorid, char *col)
or the one to get 4 bytes
ThemeColor calls for globals (UI etc) can also call NULL for *sa... this
is to be implemented still.
Next step: cleaning up interface.c for all weird colorcalls.
I had to clean up very old calls to switch matrices for 3d windows.
To make it more clear, I've introduced defines for the infamous persp()
function:
persp(PERSP_WIN); sets matrices at pixel level window
persp(PERSP_VIEW); restores matrices back to 3d drawing
persp(PERSP_STORE); only called once, to store correct matrices
I will now check on frontbuffer drawing of vertices... it's very doubtful
if it's used still correctly, was only meant for visual speed in the
early nineties you know. :)
- changed function drawcircball() in source/blender/src/drawobject.c. Circle is computed faster (no 32 calls of sin() and cos() each time witch same results).