Commit Graph

15488 Commits

Author SHA1 Message Date
Erwin Coumans
52b0a2b3db PhysicsConstraints.createConstraint:
allow to dynamically create rigid body constraints while disable collision detection between connected bodies, pass as 10th argument the flag 128

PhysiPython KX_ConstraintWrapper, setParam
export setParam(paramIndex,paramValue0,paramValue1) for Physics constraints
paramIndex 0,1,2 are linear limits, 3,4,5 are angular limits, 6,7,8 are linear motors, 9,10,11 are angular motors

For example:
disableConnectedBodies=128
cons = PhysicsConstraints.createConstraint(oid,rid,generic6dof,pivotInAx,pivotInAy,pivotInAz,angleX,angleY,angleZ,disableConnectedBodies)
#params 0,1,2 are linear limits, low,high value. if low > high then disable limit
cons.setParam(0,0,0)

I will provide an example .blend for Blender 2.49
2009-05-24 01:55:24 +00:00
Erwin Coumans
4922dd0339 fix generic 6dof constraint support -> convert 3 values into euler angles and convert those into a full constraint frame
(same values as Rigid Body constraint Generic 6DOF values), and add 'setLimit' support for generic 6DOF constraint. todo: enableMotor
2009-05-24 00:42:40 +00:00
Erwin Coumans
eb8c5f3272 Set default constraint solver mode more compatible to Blender 2.48 settings, this fixes rigid body stacking in this blend file:
http://blenderartists.org/forum/showpost.php?p=1382653&postcount=102

(todo: expose this setting in World setting GUI)

Expose contact processing threshold in Advanced GUI, next to rigid body margin, called CPT.
Default to 1, makes rigid body stacking a bit more stable, smaller values makes sliding easier (at the cost of easier jittering).
Disabled for 'dynamic' objects that don't rotate, because characters etc. always need smooth sliding.
2009-05-23 22:35:47 +00:00
Erwin Coumans
a96ce9453f Minor fixes in Bullet/constraint solving
Should  make generic 6DOF constraint more useable, and rigid body stacking more stable (warmstarting was accidently switched off)
If time allows, a few more minor last-minute 2.49 fixes might follow.
Check out http://bulletphysics.com/constraintsTutorial.blend
2009-05-23 20:02:12 +00:00
Peter Schlaile
2de8f6e328 == Sequencer ==
Fix for the fix: SDL_PauseAudio() doesn't really wait for callback to finish
which can lead to random segfaults if we set audio_scene to 0 afterwards.

So we don't do that.
2009-05-23 19:36:11 +00:00
Benoit Bolsee
5441323dca BGE: fix memleaks.
SCA_RandomActuator: The random generator was shared between replicas and not deleted. Added ref counting between replicas to allow deletion at the end.
KX_Camera: The scenegraph node was not deleted for temporary cameras (ImageMirror and shadow), causing 500 bytes leak per frame and per shadow light.
KX_GameActuator: Global dictionary buffer was not deleted after saving.
KX_MotionState: The motion state for compound child was not deleted
KX_ReplaceMeshActuator: The mesh was unnecessarily converted for each actuator and not deleted, causing large memleak.

After these fix, YoFrankie runs without memleak.
2009-05-23 14:46:43 +00:00
Benoit Bolsee
6d8d7cd768 BGE: Random sensor will produce true random sequence of events when seed is set to 0 in the GUI (the actual seed value is stored in the sensor seed attribute). Positive values will use fixed pseudo random sequence. 2009-05-23 14:40:36 +00:00
Benoit Bolsee
4e3248fb91 FIX memleak in mmap(). 2009-05-23 14:21:11 +00:00
Peter Schlaile
443df708e2 == Sequencer ==
This fixes:
[#18373] WAV with IPO CURVE: Clicking in playback

by adding linear interpolation between frames. (Old IPOs were only calculated
once per frame which will lead to clicking on steep curves)
2009-05-23 07:37:02 +00:00
Campbell Barton
3820e4f3db BGE PyController module reloading didnt check that the base of the function was a module (could be a class). 2009-05-23 04:56:37 +00:00
Campbell Barton
cfa2b4f0a5 [#18802] BGE conversion script: more attributes; updated GameTypes.py
Patch from Alex Fraser (z0r)

 - All attributes in the conversion map have been checked against the docs. More ambiguities have been resolved.
 - Added option to convert all text buffers in Blender.
 - Updated GameTypes.py: there were inconsistencies.

The script works well (causes no errors) with 0_FPS_Template.blend and vehicle_demo.blend from the
physics-2.43-physics-testfiles pack.

Caveats:
 - Conversions were checked against other deprecated attributes. I may have missed some cases where a deprecated attribute
has the same name as a non-deprecated attribute. I did catch a few though.
 - As with the last version, the conversion is purely text-based and doesn't compile the code. It's easy to create a
script that would break on conversion.

Still, it should get you 90% of the way to a converted script.
2009-05-23 03:19:47 +00:00
Ken Hughes
89049782de Python API
----------
Fix incorrect exception message.
2009-05-22 17:01:32 +00:00
Campbell Barton
794826feae Update to the bolt/nut script, I also replaced some loops with list-comprehension and use mesh.transform(matrix) rather then transforming every vert in a loop.
V2.00 22/05/09 by Aaron Keith

- Better error checking.
- Lock Nut and Hex Nut meshes added.
- Pre-sets for common metric bolts and nuts.
- Improved GUI.
- Meshes scaled to a smaller size
- Fixed bug when using crest and root percent other than 10%
- Can now create meshes in Edit Mode.  This will add to the 
  current mesh and align with the current view.
2009-05-22 12:31:27 +00:00
Campbell Barton
66ed4325f4 the debug option for BGE scripts only reloaded modules but not packages submodules.
Now reload all the submodules too.

It was also hiding the error message if there was a syntax error which wasnt so helpful.
2009-05-22 09:48:05 +00:00
Dalai Felinto
ec60c74f08 Fix for: energy IPO not supported in glsl mode (reported in the forum).
in fact I redid part of the last "fix", making it working properly now.

Before we were changing Lamp->la . This is the Blender Lamp, we shouldn't touch it.
So this part of the code is correct now.

Things that could be tackled:
- color attribute is returning negative values when NEGATIVE is toggled
- objects with no material (default gray one) still don't support lamp spots (not spot lamp but the spot of the lamps)
2009-05-22 06:12:18 +00:00
Campbell Barton
612f3b3266 Removed use of CrossVecs, DotVecs, CrossQuats and DotQuats
for all scripts except import_dxf and colladaImEx/translator.py
2009-05-22 03:45:46 +00:00
Campbell Barton
e191618cb5 - Deprecated Mathutils.CrossVecs(v1,v2) for v1.cross(v2), (same with .DotVecs -> v1.dot(v2), for CrossQuats and DotQuats too)
- Grouped Mathutils deprecated functions
- Dont include source code in bpy epydocs
2009-05-22 03:22:56 +00:00
Benoit Bolsee
7f5acd6875 BGE remove parent: unparented object keeps the linear and angular velocity it had while being parented. 2009-05-21 19:38:49 +00:00
Benoit Bolsee
036ebc5523 BGE: GUI control over frame rate, logic rate, physics rate and physics subrate.
Four new buttons in World settings to control frame rate:
fps:  Nominal frame rate in frame per second.
      Also sets the physics timestep = 1/fps
phys: Maximum number of physics timestep per game frame in case
      the actual fps is less than nominal. This allows the 
      physics to keep up with real time even if the graphics slows
      down the game.
sub:  Fixed number of simulation substeps per physic timestep.
      Improves the precision of the physics simulation. Useful for
      fast moving objects for example.
log:  Maximum number of logic steps per game frame in case the 
      actual fps is less than nominal. This allows the logic
      system to follow the physics simulation. 
      Upper bound = phys 
      (setting the value higher than phys has no effect).
      On games with heavy logic system, it is useful to set this
      value to 1, to keep logic time under control.

All these values were already accessible from Python except phys:

GameLogic.getMaxPhysicsFrame():
	Gets the maximum number of physics frame per render frame.

GameLogic.setMaxPhysicsFrame(phys):
	Sets the maximum number of physics timestep that are executed per render frame.
	Higher value allows physics to keep up with realtime even if graphics slows down the game.
	Physics timestep is fixed and equal to 1/tickrate (see setLogicTicRate)
	maxphysics/ticrate is the maximum delay of the renderer that physics can compensate.
      phys: integer
2009-05-21 18:10:19 +00:00
Remigiusz Fiedler
d54126f78e rvk1_torvk2.py patch committed by jean-michel soler (jms)
[#18765] Update of the rvk1_torvk2.py bundled script:
The script has been modified to use the last management of the modifiers in the python api and corrected too. Now it
can copy the mesh object when it is alone and also a shape keys to the second one if needed.
2009-05-21 17:54:45 +00:00
Campbell Barton
1388beebdb build without SDL in GCC 4.4 2009-05-21 14:11:12 +00:00
Benoit Bolsee
06a7155b68 BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.

Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.

2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.

Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.

Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.

Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.

Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
2009-05-21 13:32:15 +00:00
Peter Schlaile
5fc6afe240 == Sequencer ==
This fixes:
[#18007] Audio playback of a scene strip containing audio is broken.

(needed a different recursion protection than video render code, since
video and audio render can be called simultaneously because of SDL audio thread
callbacks)

Also: we don't display a wait cursor, if the scene strip has DOSEQ enabled.
(no need to wait, it is the sequencer which is realtime by definition :)
2009-05-21 10:25:40 +00:00
Campbell Barton
3f584de8ec [#18795] Subdivide Smooth can give wrong vcol
weights given by subdivide are not normalized, if that was fixed could avoid clamping.
2009-05-21 07:28:02 +00:00
Campbell Barton
3daa8bd4ef fix for [#18772] c3d_import script crashes
Patch from Roger Wickes update to 2.48 sFrame, eFrame, fps.


[#18794] GE API conversion script: 2.48 -> 2.49
patch from Alex Fraser (z0r), will test further in the next few days.
 --- 
This is text plug in and standalone script that updates Blender 2.48 Game Engine scripts to be compatible with the 2.49
API.

The script contains a mapping of attribute names to functions that do the conversion. Most of the mappings were extracted
from the documentation in GameTypes.py. Where the conversion is ambiguous, the script will not change the source except
to insert a warning as a comment. This means that the script does not completely automate the conversion process, but
will do a lot of the work.

The script still needs a fair bit of testing. Many of the mappings have not been tested and could result in broken scripts.
I'm submitting this patch now to start the review process early. I think I might need help if it is to be included in
2.49.
2009-05-20 23:31:58 +00:00
Benoit Bolsee
fcdb34f593 BGE #18664: Incorrect behavior for objects when unparented. A parented object is made static in all cases. 2009-05-20 21:34:50 +00:00
Janne Karhu
ac0766c64b Fix for [#18785] Crash rendering hair particle system 2009-05-20 12:13:37 +00:00
Benoit Bolsee
c0844b7938 BGE logic patch: fix another incompatibility with YF.
Previous patch was not sorting the state actuators. This was causing 
some problems with YoFrankie that relies on the order of actuators
when multiple state actuators are activated at once.

Active state actuators will now be sorted per object. This doesn't
change the fact that state actuators are executed before all other
actuators as before.

Incidently, made the logic loop faster.
2009-05-20 08:45:42 +00:00
Dalai Felinto
dc6ae673b1 Moving ScreenSpace methods from Rasterizer to KX_Camera (getScreenPos, getScreenVect, getScreenRay)
The modules were moved in order to access the camera internal matrixes. It will make then compatible with multiple viewports in a near future.
So far the problem I found was:
1) KX_Camera doesn't store the canvas viewport
2) RAS_ICanvas methods: GetDisplayArea and GetWindowArea are affected by multiple viewports (and they shouldn't).

Test file is here: http://www.pasteall.org/blend/68
2009-05-20 05:33:39 +00:00
Campbell Barton
fc9f893306 remove module that was never used. 2009-05-20 03:30:50 +00:00
Campbell Barton
73904597e9 - Added an intro page for the BGE docs rather then using GameLogic
- Added notes on BGE stability and modules
- updated some examples to new api syntax
- include BGL Mathutils and Geometry modules in docs
2009-05-20 01:11:56 +00:00
Ton Roosendaal
ecacef3682 Last minute mini feature:
Expanded the "10-timer" (ALT+CTRL+T) with two new test options:

- Draw entire window
- Anim step

The latter will only call animation system, no drawing.
Added this to match the testing menu in 2.5 too, so we can get good
reference performance tests.
2009-05-19 15:40:03 +00:00
Campbell Barton
1a16fb1953 BGE Py API
use PY_SET_ATTR_FAIL and PY_SET_ATTR_SUCCESS return values so the fake subclassing can know if a value failed to be set or if it was missing from the type. (with PY_SET_ATTR_MISSING)

Also noticed some other mistakes.
- KX_LightObject, setting the type didnt check for an int.
- KX_SoundActuator, didnt return an error when assigning an invalid orientation value
- KX_GameObject, worldOrientation didnt return an error value.
2009-05-19 07:16:40 +00:00
Benoit Bolsee
5bd4b25dd1 BGE bug #18762 fixed: softbody. An incompatibility between the soft body deformer and other types of deformer was causing the soft body to disappear in the game. This was the case when the soft body had an armature or simply vertex groups. 2009-05-19 06:48:36 +00:00
Campbell Barton
def33757e3 recorded game physics ipo's also have the same problem FBX export had with eulers rotations
http://www.graphicall.org/ftp/ideasman42/game_euler.png

- dont calculate handles for key added (it does them all at the end).
- was doing twice the number of curve lookup's per frame as was needed.
- test handles function that runs at the end was converting to ipo transformation values for no reason.
- when adding new curves set them to linear interpolation.
2009-05-19 05:07:52 +00:00
Benoit Bolsee
2ac81cc7ad BGE soft body: give access to the soft body collision margin in the Advanced panel. By default the collision margin is set to 0.25, which causes the soft body to somewhat float above the ground. You can decrease this value to get more realistic collision. Note that the algorithm may become unstable with lower margin. 2009-05-18 21:32:03 +00:00
Dalai Felinto
379f02f6e6 CMake + MSVC debug build fix
Initializing lResult = 0;
and removing NOP (if(!lResult) lResult = 0;

That was discussed with Genscher and Benoit in IRC.
2009-05-18 21:05:21 +00:00
Dalai Felinto
d35a556d66 Bug fix for: [#18761] GLSL Negative light option in Blender does not work in the GE 2009-05-18 20:23:38 +00:00
Campbell Barton
9c8f09d2a0 bug in copy weight group since 2.44, accessing free'd memory. 2009-05-18 14:20:16 +00:00
Campbell Barton
65bd48c896 [#18778] Lattice Vertex Groups Don't get deleted
fixed 'Copy Group' for lattice too.
2009-05-18 11:15:24 +00:00
Ton Roosendaal
b1a393e815 Bugfix #18733 & #18609 (revisited)
New imbuf scaling code, advertised as "quick and quality" gave
inacceptable noise and rounding errors. 

Check this bugreport for images that show it well:
http://projects.blender.org/tracker/?func=detail&atid=125&aid=18609&group_id=9

For release, better disable this code and fall back on perfectly
working old code. :)
2009-05-18 10:34:26 +00:00
Campbell Barton
cb96dc40e8 Sensor objects were initialized as invisible, which conflicted with initializing the invisible setting from the outliner render object (which it seems nobody knew about).
Added an 'Invisible' button to make this more clear, it seems like a display option but its also related to logic because the actuators can toggle this after the game starts.

Without this its annoying to add UV's only to set the invisible flag.

Sensor objects were not clearing the softbody gameflag
2009-05-18 10:27:09 +00:00
Benoit Bolsee
07fc2aa526 BGE #18665: Servo control and relative motion
Servo control motion actuator did not work as expected when the object
is moving on a moving platform. 

This patch introduces a new Ref field in the servo motion actuator
to set a reference object for the velocity calculation.
You can set the object during the game using the actuator "reference"
attribute; use an object name or an object reference.

The servo controller takes into account the angular velocity of the
reference object to compute the relative local velocity.
2009-05-18 08:22:51 +00:00
Benoit Bolsee
3bda88babf cmake: apply patch to link with correct python library in win32 debug mode. 2009-05-18 07:53:13 +00:00
Campbell Barton
bd7b92bfb5 Need to export the mesh-object into the bind-pose otherwise Maya complains the FBX has errors. 2009-05-18 04:33:33 +00:00
Campbell Barton
5a16f0b60c Bugfix for FBX export for animations
in 2.48 constant interpolations meant that wasnt a problem but since it now uses linear interp. you can notice errors with animated characters because the 2 eulers are not compatible.

Added optional euler_compat argument to matrix.toEuler(eul) and quat.toEuler(eul) so when getting the euler rotations from a list of matrices the animation curve will be continues.
Also added euler.makeCompatible(euler).

- warning silenced for imagepaint.c
2009-05-18 04:11:54 +00:00
Benoit Bolsee
9a40f4d2a6 BGE: bookmark option on controller to make them run before all other controllers.
A new bookmark button is available on the controller UI. 
When set, the controller is guaranteed to execute before all
other non-bookmarked controllers, provided it is scheduled 
for execution. 

This is useful for initialization scripts that run once at startup or
scripts that must set some prerequisite for the other controllers at
the start of each logic frame.

This feature is also available at python level with the "bookmark"
attribute. It can be changed during the game.

Note that if several script are bookmarked, their relative order of 
execution is not guaranteed. Make sure they don't depend on each other.
2009-05-17 21:50:31 +00:00
Dalai Felinto
9ce8a67690 BGE Dome: removing of size option and adding tilt option.
- Size adjustments can be accomplished with warp mesh data now. So we get a free spot in the GUI for a tilt option.

- Tilt option to tilt the camera (for planetarium domes).
Angle is in degree from -180 to +180. It's needed for planetarium domes (as this one http://domejunky.blogspot.com/2009/05/dome-corrected-bge.html ).

- This is the last commit regarding dome code I expected to 2.49. I consider this feature full implemented now. (working on docs now)
2009-05-17 20:37:13 +00:00
Campbell Barton
41acd3b81c While testing YoFrankie with the new API attributes found some issues...
- corrections to docs
- disallow calling controller.activate(actuator) when the controller is not active. (Raise a SystemError)
- Added 2 new attributes, CValue.name - deprecates CValue.getName(), KX_GameObject.children deprecated KX_GameObject.getChildren(), (same for getChildrenRecursive()).
2009-05-17 16:30:18 +00:00
Thomas Dinges
65796e2c07 Patch #18758 for bug #17423 by Matt D. (foom) Thanks!
"Mouse wheel zoom lost after rendering."
2009-05-17 15:09:03 +00:00