Commit Graph

1372 Commits

Author SHA1 Message Date
andy
1a72245c15 Properly release the mod lock when returning from a runtime error.
Ampere discovered that the interpreter would deadlock at runtime if it
hit such a condition during initialization.
2005-05-04 20:17:28 +00:00
ehofman
dea7b9050d Phil Cazzola:
This is a minor bug fix for sgBucketDiff().
If you crossed the bucket size boundary, the answer for dx could be wrong.

E.g.
 going from   0:0, 21:7  to 0:7, 21:7   would give you dx = 7 (correct)
 but going from 0:0, 21:7 to 0:3, 22:0 would give you dx = 6 (instead of 7)

Previously it differenced the center longitudes of the buckets.  When you
cross a boundary, the center point of the larger bucket now lies on the edge of the smaller bucket.

The result was a dx with an integer + 1/2 bucket, which rint() was rounding to the nearest even int.

This function only seems to be used in TerraGear.
2005-05-01 08:50:39 +00:00
ehofman
3bd810fedc Make use of the repeatable sg_random() function so display systems can synchronize 3d clouds too. 2005-04-30 10:00:16 +00:00
ehofman
f9cbf8361d Add a seed function that gives the same random seed within a ten minute period of time. This should be useful for synchronizing display systems. 2005-04-30 09:59:12 +00:00
ehofman
eccd4d0325 Mathias:
I have done a patch to eliminate the jitter of 3D-objects near the viewpoint
(for example 3D cockpit objects).
The problem is the roundoff accuracy of the float values used in the
scenegraph together with the transforms of the eyepoint relative to the
scenery center.

The solution will be to move the scenery center near the view point.
This way floats relative accuracy is enough to show a stable picture.

To get that right I have introduced a transform node for the scenegraph which
is responsible for that shift and uses double values as long as possible.
The scenery subsystem now has a list of all those transforms required to place
objects in the world and will tell all those transforms that the scenery
center has changed when the set_scenery_center() of the scenery subsystem is
called.
The problem was not solvable by SGModelPlacement and SGLocation, since not all
objects, especially the scenery, are placed using these classes.

The first approach was to have the scenery center exactly at the eyepoint.
This works well for the cockpit.
But then the ground jitters a bit below the aircraft. With our default views
you can't see that, but that F-18 has a camera view below the left engine
intake with the nose gear and the ground in its field of view, here I could
see that.
Having the scenery center constant will still have this roundoff problems, but
like it is now too, the roundoff error here is exactly the same in each
frame, so you will not notice any jitter.

The real solution is now to keep the scenery center constant as long as it is
in a ball of 30m radius around the view point. If the scenery center is
outside this ball, just put it at the view point.

As a sideeffect of now beeing able to switch the scenery center in the whole
scenegraph with one function call, I was able to remove a one half of a
problem when switching views, where the scenery center was far off for one or
two frames past switching from one view to the next. Also included is a fix
to the other half of this problem, where the view position was not yet copied
into a view when it is switched (at least under glut). This was responsible
for the 'Error: ...' messages of the cloud subsystem when views were
switched.
2005-04-29 14:37:27 +00:00
ehofman
e0decf1233 Mathias:
have done a patch to eliminate the jitter of 3D-objects near the viewpoint
(for example 3D cockpit objects).
The problem is the roundoff accuracy of the float values used in the
scenegraph together with the transforms of the eyepoint relative to the
scenery center.

The solution will be to move the scenery center near the view point.
This way floats relative accuracy is enough to show a stable picture.

To get that right I have introduced a transform node for the scenegraph which
is responsible for that shift and uses double values as long as possible.
The scenery subsystem now has a list of all those transforms required to place
objects in the world and will tell all those transforms that the scenery
center has changed when the set_scenery_center() of the scenery subsystem is
called.
The problem was not solvable by SGModelPlacement and SGLocation, since not all
objects, especially the scenery, are placed using these classes.

The first approach was to have the scenery center exactly at the eyepoint.
This works well for the cockpit.
But then the ground jitters a bit below the aircraft. With our default views
you can't see that, but that F-18 has a camera view below the left engine
intake with the nose gear and the ground in its field of view, here I could
see that.
Having the scenery center constant will still have this roundoff problems, but
like it is now too, the roundoff error here is exactly the same in each
frame, so you will not notice any jitter.

The real solution is now to keep the scenery center constant as long as it is
in a ball of 30m radius around the view point. If the scenery center is
outside this ball, just put it at the view point.

As a sideeffect of now beeing able to switch the scenery center in the whole
scenegraph with one function call, I was able to remove a one half of a
problem when switching views, where the scenery center was far off for one or
two frames past switching from one view to the next. Also included is a fix
to the other half of this problem, where the view position was not yet copied
into a view when it is switched (at least under glut). This was responsible
for the 'Error: ...' messages of the cloud subsystem when views were
switched.
2005-04-29 14:36:50 +00:00
ehofman
100927f16c Harald Johnsen: Fix a 'terrible' bug with culling of the clouds. 2005-04-26 20:14:37 +00:00
ehofman
bb670f6658 IRIX fixes. 2005-04-26 09:08:58 +00:00
ehofman
d37992aaf9 Harald Johnson:
Changes
=======

- corrected some strange behavior when playing with the render dialog options
- the density slider is now working : if you are fps limited and still want to see clouds in
  the distance you should play with that
- added the choice for texture resolution, its more comprehensible now (before it was
  wrongly allways choosing 64x64 textures)
- changed the initial texture size : you now have 64 texture of 64x64, this uses 1Mo of
  texture memory (before it was 20 texture of  256x256, that took more memory and there was
  not enought impostors)
- sun vector is now right so the lighting is a bit better
- removed useless sort and light computations for impostors, this should save a lot of cpu
- blending of distant cloud is more accurate now
- clouds are now positioned correctly, they don't try to escape you anymore
- no more red/white boxes around cloud
- textures are now filtered (no more big pixels)

known bugs
==========

- distant objects are seen in front of clouds
2005-04-26 08:30:38 +00:00
ehofman
9048ee533d Don't refference GLUT but GLU instead. 2005-04-24 13:55:20 +00:00
ehofman
2b1e5927ca This one time I did a commit using Linux. <sigh> 2005-04-24 11:45:34 +00:00
ehofman
b5e03030d1 Harald Johnson:
- new and updated sources for the new volumetric clouds
- 2 new textures for the clouds
- an update to the render dialog to enable/disable and change a few parameters
  for the new clouds
2005-04-24 11:16:50 +00:00
andy
65056bfa72 Support for a "forindex(idx; list) {...}" construct analagous to
foreach, except that the variable gets the index instead of the list
element.  Should be useful, and took almost no code to implement.

Support for operator/assignment syntax: +=, -=, *=, /= and ~= now do
what you think they should.

Library support for a bind() function (see the docs Andy is still
writing), allowing runtime modifications to function lexical
environments.
2005-04-22 21:54:16 +00:00
andy
c50bb90374 Fix clamping of the minimum hash size, because the Melchior discovered
that the column math goes wacky when lgalloced is allowed to be
  zero.
Augment the find() function to take a starting index.
Fix strc() to use a default index of zero.
Fix parser precedence of TOK_MINUS, so that "a-b-1" means (a-b)-1 and
  not a-(b-1).
2005-04-19 14:19:46 +00:00
ehofman
ec4fc265e0 Non gcc fixes. 2005-04-19 12:30:12 +00:00
andy
8ea41af5c4 Fix crash in the code generator when compiling a (now illegal, because
"var" is a reserved word) expresssion of the vorm "var=<expr>".
2005-04-18 20:43:29 +00:00
andy
966331dac7 Upgrade to nasal 1.0 test candidate 2005-04-18 19:48:47 +00:00
andy
cf056bace7 Fix boolean semantics so that the empty string evaluates to false, and
numeric strings are false if their numeric values are false.
2005-03-30 18:45:01 +00:00
ehofman
405a455906 Melchior FRANZ:
Re-organisation: <diffuse>, <ambient>, <emission>, <specular> are
now groups with members <red>, <green>, <blue>, <factor>, <offset>,
and their <*-prop> forms. Additionally, there's an option <property-base>
that can be used to set a path that is prepended to all <*-prop> paths.
It defaults to an empty string. Rationale: see model-howto.html.
2005-03-28 09:13:45 +00:00
andy
3a8b431a5b Don't parse a single "e" or "E" as a numerical zero. You need a
numerical prefix to use the 1.0e12 notation, "e" alone is not enough.
2005-03-22 20:28:47 +00:00
ehofman
3ce0c17237 Melchior FRANZ:
here is the promised material animation. It looks a bit longish, but that
wasn't avoidable -- there are simply too many parameters to consider. I tried
hard, though, to make the animation fast by only doing the necessary stuff.
It doesn't affect the frame rate here with my test model. The animation is
heavily based on Jim's "material-emission" animation.

* implementation of the "material" animation (this required to make the
  texture path available) + documentation update ($FG_ROOT/Docs/)
* fix some more return values (texture animations, and select) for the
  shadow problem (and some in anticipation of other problems  :-)
* fix compiler warning
2005-03-22 13:12:51 +00:00
ehofman
61a2e0f104 Melchior FRANZ:
the cause for the disappearing shadows is, that SimGear doesn't tell plib
to call the pre-traversal-callback function on culled objects. These calls,
however, are necessary to execute the transform animation that does, for
example, translate a shadow back into the frustum! Curretnly, the callback
is only executed, and the shadow only magically pops up again, when the object
enters the frustum because the view has changed significantly.

The plib documentation does only talk about TRUE and FALSE for possible
return values from the pre-traversal-callback. But src/ssgEntity.cxx reads
like this:

   int ssgEntity::preTravTests ( int *test_needed, int which )
   ...
       int result = (*preTravCB)(this,which) ;

       if ( result == 0 ) return FALSE ;
       if ( result == 2 ) *test_needed = 0 ;
   ...

So the return value needs to be 2 to bypass the cull test for pretraversal,
and get the pretraversal in any case. I only changed the return values in
four animations: scale, rotate, translate, and range, because these are
the most likely to move an object out of the frustum. It's not necessary
for blend/alpha/texture manipulation etc. Of course, this is a bit more work
for plib, but the performance will probably not be affected, because:

* these four animations are mainly used for the aircraft model (the spin
  and billboard (trees!) animations are not affected)

* the number of extra nodes to process is quite low

* a part of the time spent for the extra nodes to be processed, was before
  used for workarounds that are now not necessary any more

I didn't observe a frame rate drop, at least.
2005-03-19 10:19:30 +00:00
andy
7c44251216 Oops, fixed the wrong test 2005-03-12 15:51:37 +00:00
andy
26e70664d6 Off by one error when printing exact poweres of ten 2005-03-12 15:49:53 +00:00
andy
8ac27cc798 Fix an infinite loop (due to an overflow condition) when printing some
very large numbers.
2005-03-11 21:49:31 +00:00
andy
d314164fed Fix the fixes. Note that "." had the same problem as "+" and "-", and
that we can still match non-identical constants if they are both
strings with the same numerical value.
2005-03-11 20:39:07 +00:00
andy
d2cbed151b Don't parse the strings "+" and "-" as numerical zeros. Also fix the
code generation of constant objects to use real identity and not Nasal
equality, so (e.g.) the constants 1 (number) and "1.0" (string) do not
get turned into the same object in the generated code.
2005-03-11 19:07:06 +00:00
ehofman
fc06ae58b2 Ima Sudonim:
I have (hopefully) generated a patch for a previously mentioned simgear  problem for a hang condition in mac os x.  Mentioned in  <http://baron.flightgear.org/pipermail/flightgear-devel/2005-February/ 035004.html>
2005-03-10 08:58:48 +00:00
ehofman
a8768c78a2 automake 1.8+ fixes 2005-02-15 18:13:15 +00:00
ehofman
ee8763f60d More MacOS X fixes 2005-02-12 12:44:46 +00:00
ehofman
db633330fe Fixes from Norman for users running Cugwin with the XServer package installed. 2005-02-11 15:19:04 +00:00
ehofman
c1ffafd663 MacOS X fix(?) 2005-02-11 15:07:22 +00:00
ehofman
72f35dc914 Comment out GLX code for MacOS and (hopefully) add some MacOS AGL compattible code. More needs to be done though. 2005-02-01 10:35:43 +00:00
ehofman
e5f82f53b9 MacOS doesn't have glx.h 2005-01-31 18:29:38 +00:00
ehofman
e39e6893e0 Jim Wilson:
Fix a couple of loose ends and missed edits on the earlier patch.  For the
most part no change in functionality.
2005-01-31 18:21:12 +00:00
ehofman
9ab77d65f4 Cygwin fixes 2005-01-31 18:07:40 +00:00
ehofman
8ed96cad1d Windows fixes. 2005-01-29 11:44:01 +00:00
ehofman
7795eb8239 Jim Wilson:
This patch adds support to the model animation system for modifying emissive
states on the fly so that it is possible to make "lights" appear to dimm.

This is an example of a configuration entry which should explain how it is used:


 <animation>
  <type>material-emission</type>
  <object-name>Face</object-name>
  <property>/controls/lighting/instruments-norm</property>
  <emiss-red>1.0</emiss-red>
  <emiss-green>0.8</emiss-green>
  <emiss-blue>0.5</emiss-blue>
 </animation>

Note the color entries are the emissive colors when the "property" value is
1.0.  They are useful for tinting the light.   The "property" itself must be
float or double and is clamped to values between 0 ~ 1.0 inclusively.   The
"property" value is multiplied against the colors to get the actual material
properties.  Thus property value 0.0 = darkest, and 1.0 = brightest.
2005-01-29 10:31:25 +00:00
ehofman
207c7ab1e0 MSVC fix. 2005-01-28 15:23:26 +00:00
ehofman
27af79684f Frederic Bouvier:
code.c is C code ( according to the file extension ), so variables should be declared at the beginning of the function.
2005-01-28 15:21:29 +00:00
ehofman
6b61a8eed1 use a proper delete[] 2005-01-28 15:15:23 +00:00
ehofman
181e6eac75 MSVC fixes 2005-01-28 09:32:57 +00:00
ehofman
fd1979857c Fix an NVIDIA problem. 2005-01-27 17:49:22 +00:00
ehofman
448bc3facd Add a RenderTexture test program. 2005-01-27 10:56:22 +00:00
ehofman
97cabadb88 Melchior FRANZ:
If alcOpenDevice( NULL ) is NULL, then context is never assigned a
value, and it's pointless to ask for it in the next "if". But as the
ALCcontext that context points to doesn't seem to be fully defined
(OpenAL bug), valgrind still complains ...


Erik Hofman:
Extend this some further and define context=0 otherwise and check for
context != 0 before using it.
2005-01-27 10:47:09 +00:00
ehofman
8e284a70b7 Melchior FRANZ:
Trying to find the bug in tower.cxx (that crashes fgfs quite frequently
for me!), I'm playing with valgrind again. Until I'm in the ATC subsystem
there will be some other bugs and nitpicking along the way.

valgrind doesn't like that imgage->tmp is once allocated with new and
once with new[], sometimes with malloc() (via map), and sometimes freed
with delete (not delete[]!) and sometimes with free(). With simple types
such as GLubyte this shouldn't really make a difference, but anyway.

Also, I promised that I'd send patches for "if (foo) delete foo;" as
I'm making other changes to concerned files. texture.cxx is one with a
few occurrences thereof. (Remember: C++ explicitly allows to delete
null-pointers, so this check is redundant, and hence not tolerated in
other projects, such as KDE. Doesn't have to impress us, of course.  :-)

Also, fixes 4 signed/unsigned warnings (gcc 3.3.4)
2005-01-27 10:42:31 +00:00
ehofman
73f9febe06 Add Mark Haris' RenderTexture class based on SimGear's extesion support files. 2005-01-27 10:39:15 +00:00
andy
6a6cc22e9c Move error handling in setupFuncall above the stack frame creation.
The error properly belongs to the enclosing scope, not the called
(non-)function.  This bug was fixed a few months back in my private
tree, but Melchior just discovered that the new Concorde scripts
tickle it.  I really need to re-synchronize SimGear with my own Nasal
tree...
2005-01-25 22:37:22 +00:00
ehofman
b293639b76 Add a bunch of extensions in preparation of render-to-texture support. 2005-01-25 18:33:59 +00:00
curt
f06036be09 Frederic Bouvier:
The Beaver triggered a problem ( uninitialized variable ). Here is the updated
code.
2005-01-24 21:46:12 +00:00