Merged changes in the trunk up to revision 38543.

Conflicts resolved:
doc/python_api/sphinx_doc_gen.py
source/blender/blenkernel/CMakeLists.txt
source/blender/makesdna/DNA_material_types.h
source/blender/render/intern/source/pipeline.c
source/creator/CMakeLists.txt
This commit is contained in:
2011-07-20 23:33:10 +00:00
395 changed files with 34491 additions and 33122 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
"""
Basic Sound Playback
++++++++++++++++++++
This script shows how to use the classes: :class:`Device`, :class:`Factory` and
:class:`Handle`.
"""
import aud
device = aud.device()
# load sound file (it can be a video file with audio)
factory = aud.Factory('music.ogg')
# play the audio, this return a handle to control play/pause
handle = device.play(sound)
# if the audio is not too big and will be used often you can buffer it
factory_buffered = aud.Factory.buffer(sound)
handle_buffered = device.play(buffered)
# stop the sounds (otherwise they play until their ends)
handle.stop()
handle_buffered.stop()

View File

@@ -0,0 +1,37 @@
"""
Basic Physics Constraint
++++++++++++++++++++++
Example of how to create a hinge Physics Constraint between two objects.
"""
from bge import logic
from bge import constraints
# get object list
objects = logic.getCurrentScene().objects
# get object named Object1 and Object 2
object_1 = objects["Object1"]
object_2 = objects["Object2"]
# want to use Edge constraint type
constraint_type = 2
# get Object1 and Object2 physics IDs
physics_id_1 = object_1.getPhysicsId()
physics_id_2 = object_2.getPhysicsId()
# Use bottom right edge of Object1 for hinge position
edge_position_x = 1.0
edge_position_y = 0.0
edge_position_z = -1.0
# use Object1 y axis for angle to point hinge
edge_angle_x = 0.0
edge_angle_y = 1.0
edge_angle_z = 0.0
# create an edge constraint
constraints.createConstraint( physics_id_1, physics_id_2,
constraint_type,
edge_position_x, edge_position_y, edge_position_z,
edge_angle_x, edge_angle_y, edge_angle_z )

View File

@@ -0,0 +1,37 @@
"""
Texture replacement
++++++++++++++++++++++
Example of how to replace a texture in game with an external image.
createTexture() and removeTexture() are to be called from a module Python
Controller.
"""
from bge import logic
from bge import texture
def createTexture(cont):
"""Create a new Dynamic Texture"""
object = cont.owner
# get the reference pointer (ID) of the internal texture
ID = texture.materialID(obj, 'IMoriginal.png')
# create a texture object
object_texture = texture.Texture(object, ID)
# create a new source with an external image
url = logic.expandPath("//newtexture.jpg")
new_source = texture.ImageFFmpeg(url)
# the texture has to be stored in a permanent Python object
logic.texture = object_texture
# update/replace the texture
logic.texture.source = new_source
logic.texture.refresh(False)
def removeTexture(cont):
"""Delete the Dynamic Texture, reversing back the final to its original state."""
try:
del logic.texture
except:
pass

View File

@@ -0,0 +1,32 @@
"""
Basic Video Playback
++++++++++++++++++++++
Example of how to replace a texture in game with a video. It needs to run everyframe
"""
import bge
from bge import texture
from bge import logic
cont = logic.getCurrentController()
obj = cont.owner
# the creation of the texture must be done once: save the
# texture object in an attribute of bge.logic module makes it persistent
if not hasattr(logic, 'video'):
# identify a static texture by name
matID = texture.materialID(obj, 'IMvideo.png')
# create a dynamic texture that will replace the static texture
logic.video = texture.Texture(obj, matID)
# define a source of image for the texture, here a movie
movie = logic.expandPath('//trailer_400p.ogg')
logic.video.source = texture.VideoFFmpeg(movie)
logic.video.source.scale = True
# quick off the movie, but it wont play in the background
logic.video.source.play()
# you need to call this function every frame to ensure update of the texture.
logic.video.refresh(True)

View File

@@ -0,0 +1,41 @@
"""
Hello World Text Example
++++++++++++++++++++++++
Blender Game Engine example of using the blf module. For this module to work we
need to use the OpenGL wrapper :class:`~bgl` as well.
"""
# import game engine modules
from bge import render
from bge import logic
# import stand alone modules
import bgl
import blf
def init():
"""init function - runs once"""
# create a new font object, use external ttf file
font_path = logic.expandPath('//Zeyada.ttf')
# store the font indice - to use later
logic.font_id = blf.load(font_path)
# set the font drawing routine to run every frame
scene = logic.getCurrentScene()
scene.post_draw=[write]
def write():
"""write on screen"""
width = render.getWindowWidth()
height = render.getWindowHeight()
# OpenGL setup
bgl.glMatrixMode(bgl.GL_PROJECTION)
bgl.glLoadIdentity()
bgl.gluOrtho2D(0, width, 0, height)
bgl.glMatrixMode(bgl.GL_MODELVIEW)
bgl.glLoadIdentity()
# BLF drawing routine
font_id = logic.font_id
blf.position(font_id, (width*0.2), (height*0.3), 0)
blf.size(font_id, 50, 72)
blf.draw(font_id, "Hello World")

View File

@@ -61,10 +61,10 @@ bpy.utils.register_class(CustomRenderEngine)
# Otherwise most of the UI will be empty when the engine is selected.
# In this example, we need to see the main render image button and
# the material preview panel.
import properties_render
from bl_ui import properties_render
properties_render.RENDER_PT_render.COMPAT_ENGINES.add('custom_renderer')
del properties_render
import properties_material
from bl_ui import properties_material
properties_material.MATERIAL_PT_preview.COMPAT_ENGINES.add('custom_renderer')
del properties_material

View File

@@ -0,0 +1,199 @@
Game Engine bge.constraints Module
==================================
.. note::
This documentation is still very weak, and needs some help!
.. function:: createConstraint([obj1, [obj2, [restLength, [restitution, [damping]]]]])
Creates a constraint.
:arg obj1: first object on Constraint
:type obj1: :class:'bge.types.KX_GameObject' #I think, there is no error when I use one
:arg obj2: second object on Constraint
:type obj2: :class:'bge.types.KX_GameObject' #too
:arg restLength: #to be filled
:type restLength: float
:arg restitution: #to be filled
:type restitution: float
:arg damping: #to be filled
:type damping: float
.. attribute:: error
Simbolic constant string that indicates error.
.. function:: exportBulletFile(filename)
export a .bullet file
:arg filename: File name
:type filename: string
.. function:: getAppliedImpulse(constraintId)
:arg constraintId: The id of the constraint.
:type constraintId: int
:return: the most recent applied impulse.
:rtype: float
.. function:: getVehicleConstraint(constraintId)
:arg constraintId: The id of the vehicle constraint.
:type constraintId: int
:return: a vehicle constraint object.
:rtype: :class:'KX_VehicleWrapper'
.. function:: removeConstraint(constraintId)
Removes a constraint.
:arg constraintId: The id of the constraint to be removed.
:type constraintId: int
.. function:: setCcdMode(ccdMode)
..note::
Very experimental, not recommended
Sets the CCD mode in the Physics Environment.
:arg ccdMode: The new CCD mode.
:type ccdMode: int
.. function:: setContactBreakingTreshold(breakingTreshold)
.. note::
Reasonable default is 0.02 (if units are meters)
Sets the contact breaking treshold in the Physics Environment.
:arg breakingTreshold: The new contact breaking treshold.
:type breakingTreshold: float
.. function:: setDeactivationAngularTreshold(angularTreshold)
Sets the deactivation angular treshold.
:arg angularTreshold: New deactivation angular treshold.
:type angularTreshold: float
.. function:: setDeactivationLinearTreshold(linearTreshold)
Sets the deactivation linear treshold.
:arg linearTreshold: New deactivation linear treshold.
:type linearTreshold: float
.. function:: setDeactivationTime(time)
Sets the time after which a resting rigidbody gets deactived.
:arg time: The deactivation time.
:type time: float
.. function:: setDebugMode(mode)
Sets the debug mode.
Debug modes:
- No debug: 0
- Draw wireframe: 1
- Draw Aabb: 2 #What's Aabb?
- Draw freatures text: 4
- Draw contact points: 8
- No deactivation: 16
- No help text: 32
- Draw text: 64
- Profile timings: 128
- Enable sat comparision: 256
- Disable Bullet LCP: 512
- Enable CCD: 1024
- Draw Constraints: #(1 << 11) = ?
- Draw Constraint Limits: #(1 << 12) = ?
- Fast Wireframe: #(1 << 13) = ?
:arg mode: The new debug mode.
:type mode: int
.. function:: setGravity(x, y, z)
Sets the gravity force.
:arg x: Gravity X force.
:type x: float
:arg y: Gravity Y force.
:type y: float
:arg z: Gravity Z force.
:type z: float
.. function:: setLinearAirDamping(damping)
Not implemented.
.. function:: setNumIterations(numiter)
Sets the number of iterations for an iterative constraint solver.
:arg numiter: New number of iterations.
:type numiter: int
.. function:: setNumTimeSubSteps(numsubstep)
Sets the number of substeps for each physics proceed. Tradeoff quality for performance.
:arg numsubstep: New number of substeps.
:type numsubstep: int
.. function:: setSolverDamping(damping)
..note::
Very experimental, not recommended
Sets the solver damping.
:arg damping: New damping for the solver.
:type damping: float
.. function:: setSolverTau(tau)
.. note::
Very experimental, not recommended
Sets the solver tau.
:arg tau: New tau for the solver.
:type tau: float
.. function:: setSolverType(solverType)
.. note::
Very experimental, not recommended
Sets the solver type.
:arg solverType: The new type of the solver.
:type solverType: int
.. function:: setSorConstant(sor)
.. note::
Very experimental, not recommended
Sets the sor constant.
:arg sor: New sor value.
:type sor: float
.. function:: setUseEpa(epa)
Not implemented.

View File

@@ -1,5 +1,5 @@
Game Engine bge.events module
Game Engine bge.events Module
=============================
*****

View File

@@ -17,7 +17,7 @@ Module to access logic functions, imported automatically into the python control
# To get the game object this controller is on:
obj = cont.owner
:class:`~bge.types.KX_GameObject` and :class:`~bge.types.KX_Camera` or :class:`bge.types.~KX_LightObject` methods are available depending on the type of object
:class:`~bge.types.KX_GameObject` and :class:`~bge.types.KX_Camera` or :class:`~bge.types.KX_LightObject` methods are available depending on the type of object
.. code-block:: python

View File

@@ -0,0 +1,549 @@
Game Engine bge.texture Module
==============================
.. note::
This documentation is still very weak, and needs some help! Right now they are mostly a collection
of the docstrings found in the bge.texture source code + some random places filled with text.
*****
Intro
*****
The bge.texture module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture, memory buffer, camera render or a mix of that.
The video and image files can be loaded from the internet using an URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect: blue screen, color band, gray, normal map.
bge.texture uses FFmpeg to load images and videos. All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to::
* AVI
* Ogg
* Xvid
* Theora
* dv1394 camera
* video4linux capture card (this includes many webcams)
* videoForWindows capture card (this includes many webcams)
* JPG
The principle is simple: first you identify a texture on an existing object using
the :materialID: function, then you create a new texture with dynamic content
and swap the two textures in the GPU.
The GE is not aware of the substitution and continues to display the object as always,
except that you are now in control of the texture.
When the texture object is deleted, the new texture is deleted and the old texture restored.
.. module:: bge.texture
.. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0])
FFmpeg video source
.. attribute:: status
video status
.. attribute:: range
replay range
.. attribute:: repeat
repeat count, -1 for infinite repeat
:type: int
.. attribute:: framerate
frame rate
:type: float
.. attribute:: valid
Tells if an image is available
:type: bool
.. attribute:: image
image data
.. attribute:: size
image size
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: flip
flip image vertically
.. attribute:: filter
pixel filter
.. attribute:: preseek
number of frames of preseek
:type: int
.. attribute:: deinterlace
deinterlace image
:type: bool
.. method:: play()
Play (restart) video
.. method:: pause()
pause video
.. method:: stop()
stop video (play will replay it from start)
.. method:: refresh()
Refresh video - get its status
.. class:: ImageFFmpeg(file)
FFmpeg image source
.. attribute:: status
video status
.. attribute:: valid
Tells if an image is available
:type: bool
.. attribute:: image
image data
.. attribute:: size
image size
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: flip
flip image vertically
.. attribute:: filter
pixel filter
.. method:: refresh()
Refresh image, i.e. load it
.. method:: reload([newname])
Reload image, i.e. reopen it
.. class:: ImageBuff()
Image source from image buffer
.. attribute:: filter
pixel filter
.. attribute:: flip
flip image vertically
.. attribute:: image
image data
.. method:: load(imageBuffer, width, height)
Load image from buffer
.. method:: plot(imageBuffer, width, height, positionX, positionY)
update image buffer
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: size
image size
.. attribute:: valid
bool to tell if an image is available
.. class:: ImageMirror(scene)
Image source from mirror
.. attribute:: alpha
use alpha in texture
.. attribute:: background
background color
.. attribute:: capsize
size of render area
.. attribute:: clip
clipping distance
.. attribute:: filter
pixel filter
.. attribute:: flip
flip image vertically
.. attribute:: image
image data
.. method:: refresh(imageMirror)
Refresh image - invalidate its current content
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: size
image size
.. attribute:: valid
bool to tell if an image is available
.. attribute:: whole
use whole viewport to render
.. class:: ImageMix()
Image mixer
.. attribute:: filter
pixel filter
.. attribute:: flip
flip image vertically
.. method:: getSource(imageMix)
get image source
.. method:: getWeight(imageMix)
get image source weight
.. attribute:: image
image data
.. method:: refresh(imageMix)
Refresh image - invalidate its current content
.. attribute:: scale
fast scale of image (near neighbour)
.. method:: setSource(imageMix)
set image source
.. method:: setWeight(imageMix)
set image source weight
.. attribute:: valid
bool to tell if an image is available
.. class:: ImageRender(scene, camera)
Image source from render
.. attribute:: alpha
use alpha in texture
.. attribute:: background
background color
.. attribute:: capsize
size of render area
.. attribute:: filter
pixel filter
.. attribute:: flip
flip image vertically
.. attribute:: image
image data
.. method:: refresh(imageRender)
Refresh image - invalidate its current content
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: size
image size
.. attribute:: valid
bool to tell if an image is available
.. attribute:: whole
use whole viewport to render
.. class:: ImageViewport()
Image source from viewport
.. attribute:: alpha
use alpha in texture
.. attribute:: capsize
size of viewport area being captured
.. attribute:: filter
pixel filter
.. attribute:: flip
flip image vertically
.. attribute:: image
image data
.. attribute:: position
upper left corner of captured area
.. method:: refresh(imageViewport)
Refresh image - invalidate its current content
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: size
image size
.. attribute:: valid
bool to tell if an image is available
.. attribute:: whole
use whole viewport to capture
.. class:: Texture(gameObj)
Texture objects
.. attribute:: bindId
OpenGL Bind Name
.. method:: close(texture)
Close dynamic texture and restore original
.. attribute:: mipmap
mipmap texture
.. method:: refresh(texture)
Refresh texture from source
.. attribute:: source
source of texture
.. class:: FilterBGR24()
Source filter BGR24 objects
.. class:: FilterBlueScreen()
Filter for Blue Screen objects
.. attribute:: color
blue screen color
.. attribute:: limits
blue screen color limits
.. attribute:: previous
previous pixel filter
.. class:: FilterColor()
Filter for color calculations
.. attribute:: matrix
matrix [4][5] for color calculation
.. attribute:: previous
previous pixel filter
.. class:: FilterGray()
Filter for gray scale effect
.. attribute:: previous
previous pixel filter
.. class:: FilterLevel()
Filter for levels calculations
.. attribute:: levels
levels matrix [4] (min, max)
.. attribute:: previous
previous pixel filter
.. class:: FilterNormal()
Filter for Blue Screen objects
.. attribute:: colorIdx
index of color used to calculate normal (0 - red, 1 - green, 2 - blue)
.. attribute:: depth
depth of relief
.. attribute:: previous
previous pixel filter
.. class:: FilterRGB24()
Returns a new input filter object to be used with :class:`ImageBuff` object when the image passed
to the ImageBuff.load() function has the 3-bytes pixel format BGR.
.. class:: FilterRGBA32()
Source filter RGBA32 objects
.. function:: getLastError()
Last error that occurred in a bge.texture function.
:return: the description of the last error occurred in a bge.texture function.
:rtype: string
.. function:: imageToArray(image,mode)
Returns a :class:`~bgl.buffer` corresponding to the current image stored in a texture source object.
:arg image: Image source object.
:type image: object of type :class:`VideoFFmpeg`, :class:`ImageFFmpeg`, :class:`ImageBuff`, :class:`ImageMix`, :class:`ImageRender`, :class:`ImageMirror` or :class:`ImageViewport`
:arg mode: optional argument representing the pixel format.
You can use the characters R, G, B for the 3 color channels, A for the alpha channel,
0 to force a fixed 0 color channel and 1 to force a fixed 255 color channel.
Example: "BGR" will return 3 bytes per pixel with the Blue, Green and Red channels in that order.
"RGB1" will return 4 bytes per pixel with the Red, Green, Blue channels in that order and the alpha channel forced to 255.
The default mode is "RGBA".
:type mode: string
:rtype: :class:`~bgl.buffer`
:return: A object representing the image as one dimensional array of bytes of size (pixel_size*width*height),
line by line starting from the bottom of the image. The pixel size and format is determined by the mode
parameter.
.. function materialID(object,name)
Returns a numeric value that can be used in :class:`Texture` to create a dynamic texture.
The value corresponds to an internal material number that uses the texture identified
by name. name is a string representing a texture name with IM prefix if you want to
identify the texture directly. This method works for basic tex face and for material,
provided the material has a texture channel using that particular texture in first
position of the texture stack. name can also have MA prefix if you want to identify
the texture by material. In that case the material must have a texture channel in first
position.
If the object has no material that matches name, it generates a runtime error. Use try/except to catch the exception.
Ex: bge.texture.materialID(obj, 'IMvideo.png')
:arg object: the game object that uses the texture you want to make dynamic
:type object: game object
:arg name: name of the texture/material you want to make dynamic.
:type name: string
:rtype: integer
.. function setLogFile(filename)
Sets the name of a text file in which runtime error messages will be written, in addition to the printing
of the messages on the Python console. Only the runtime errors specific to the VideoTexture module
are written in that file, ordinary runtime time errors are not written.
:arg filename: name of error log file
:type filename: string
:rtype: integer

1889
doc/python_api/rst/bgl.rst Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -700,6 +700,23 @@ Renamed
2.57 to 2.58
============
bpy_extras
----------
Added
^^^^^
* :mod:`bpy_extras`
* :mod:`bpy_extras.view3d_utils`
Moved
^^^^^
* io_utils -> :mod:`bpy_extras.io_utils`
* image_utils -> :mod:`bpy_extras.image_utils`
* mesh_utils -> :mod:`bpy_extras.mesh_utils`
* object_utils -> :mod:`bpy_extras.object_utils`
bpy.types.RenderSettings
------------------------

View File

@@ -29,15 +29,15 @@ For HTML generation
./blender.bin --background --python doc/python_api/sphinx_doc_gen.py
This will generate python files in doc/python_api/sphinx-in/,
assuming that ./blender.bin is or links to the blender executable
This will generate python files in doc/python_api/sphinx-in/
providing ./blender.bin is or links to the blender executable
- Generate html docs by running...
cd doc/python_api
sphinx-build sphinx-in sphinx-out
assuming that you have sphinx 1.0.7 installed
This requires sphinx 1.0.7 to be installed.
For PDF generation
------------------
@@ -48,6 +48,15 @@ For PDF generation
make
'''
# Check we're running in blender
if __import__("sys").modules.get("bpy") is None:
print("\nError, this script must run from inside blender2.5")
print(script_help_msg)
import sys
sys.exit()
# Switch for quick testing
if 1:
# full build
@@ -58,7 +67,7 @@ if 1:
else:
# for testing so doc-builds dont take so long.
EXCLUDE_MODULES = (
# "bpy.context",
"bpy.context",
"bpy.app",
"bpy.path",
"bpy.data",
@@ -67,8 +76,8 @@ else:
"bpy.context",
"bpy.types", # supports filtering
"bpy.ops", # supports filtering
#"bpy_extras",
"bge",
"bpy_extras",
# "bge",
"aud",
"bgl",
"blf",
@@ -988,6 +997,7 @@ def rna2sphinx(BASEPATH):
fw("\n")
fw("* `Quickstart Intro <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>`_ if you are new to scripting in blender and want to get you're feet wet!\n")
fw("* `Blender/Python Overview <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Overview>`_ for a more complete explanation of python integration in blender\n")
fw("\n")
fw("===================\n")
fw("Application Modules\n")
@@ -1029,8 +1039,8 @@ def rna2sphinx(BASEPATH):
fw(" mathutils.geometry.rst\n\n")
if "Freestyle" not in EXCLUDE_MODULES:
fw(" Freestyle.rst\n\n")
# XXX TODO
#fw(" bgl.rst\n\n")
if "bgl" not in EXCLUDE_MODULES:
fw(" bgl.rst\n\n")
if "blf" not in EXCLUDE_MODULES:
fw(" blf.rst\n\n")
if "aud" not in EXCLUDE_MODULES:
@@ -1049,7 +1059,9 @@ def rna2sphinx(BASEPATH):
fw(" bge.types.rst\n\n")
fw(" bge.logic.rst\n\n")
fw(" bge.render.rst\n\n")
fw(" bge.texture.rst\n\n")
fw(" bge.events.rst\n\n")
fw(" bge.constraints.rst\n\n")
# rna generated change log
fw("========\n")
@@ -1160,14 +1172,16 @@ def rna2sphinx(BASEPATH):
import mathutils.geometry as module
pymodule2sphinx(BASEPATH, "mathutils.geometry", module, "Geometry Utilities")
if "mathutils.geometry" not in EXCLUDE_MODULES:
if "blf" not in EXCLUDE_MODULES:
import blf as module
pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing")
# XXX TODO
#import bgl as module
#pymodule2sphinx(BASEPATH, "bgl", module, "Blender OpenGl wrapper")
#del module
if "bgl" not in EXCLUDE_MODULES:
#import bgl as module
#pymodule2sphinx(BASEPATH, "bgl", module, "Blender OpenGl wrapper")
#del module
import shutil
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bgl.rst"), BASEPATH)
if "aud" not in EXCLUDE_MODULES:
import aud as module
@@ -1181,7 +1195,9 @@ def rna2sphinx(BASEPATH):
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.types.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.logic.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.render.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.texture.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.events.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.constraints.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "change_log.rst"), BASEPATH)
@@ -1206,72 +1222,67 @@ def rna2sphinx(BASEPATH):
def main():
import bpy
if 'bpy' not in dir():
print("\nError, this script must run from inside blender2.5")
print(script_help_msg)
import shutil
script_dir = os.path.dirname(__file__)
path_in = os.path.join(script_dir, "sphinx-in")
path_out = os.path.join(script_dir, "sphinx-out")
path_examples = os.path.join(script_dir, "examples")
# only for partial updates
path_in_tmp = path_in + "-tmp"
if not os.path.exists(path_in):
os.mkdir(path_in)
for f in os.listdir(path_examples):
if f.endswith(".py"):
EXAMPLE_SET.add(os.path.splitext(f)[0])
# only for full updates
if _BPY_FULL_REBUILD:
shutil.rmtree(path_in, True)
shutil.rmtree(path_out, True)
else:
import shutil
# write here, then move
shutil.rmtree(path_in_tmp, True)
script_dir = os.path.dirname(__file__)
path_in = os.path.join(script_dir, "sphinx-in")
path_out = os.path.join(script_dir, "sphinx-out")
path_examples = os.path.join(script_dir, "examples")
# only for partial updates
path_in_tmp = path_in + "-tmp"
rna2sphinx(path_in_tmp)
if not os.path.exists(path_in):
os.mkdir(path_in)
if not _BPY_FULL_REBUILD:
import filecmp
for f in os.listdir(path_examples):
if f.endswith(".py"):
EXAMPLE_SET.add(os.path.splitext(f)[0])
# now move changed files from 'path_in_tmp' --> 'path_in'
file_list_path_in = set(os.listdir(path_in))
file_list_path_in_tmp = set(os.listdir(path_in_tmp))
# only for full updates
if _BPY_FULL_REBUILD:
shutil.rmtree(path_in, True)
shutil.rmtree(path_out, True)
else:
# write here, then move
shutil.rmtree(path_in_tmp, True)
# remove deprecated files that have been removed.
for f in sorted(file_list_path_in):
if f not in file_list_path_in_tmp:
print("\tdeprecated: %s" % f)
os.remove(os.path.join(path_in, f))
rna2sphinx(path_in_tmp)
# freshen with new files.
for f in sorted(file_list_path_in_tmp):
f_from = os.path.join(path_in_tmp, f)
f_to = os.path.join(path_in, f)
if not _BPY_FULL_REBUILD:
import filecmp
do_copy = True
if f in file_list_path_in:
if filecmp.cmp(f_from, f_to):
do_copy = False
# now move changed files from 'path_in_tmp' --> 'path_in'
file_list_path_in = set(os.listdir(path_in))
file_list_path_in_tmp = set(os.listdir(path_in_tmp))
if do_copy:
print("\tupdating: %s" % f)
shutil.copy(f_from, f_to)
'''else:
print("\tkeeping: %s" % f) # eh, not that useful'''
# remove deprecated files that have been removed.
for f in sorted(file_list_path_in):
if f not in file_list_path_in_tmp:
print("\tdeprecated: %s" % f)
os.remove(os.path.join(path_in, f))
# freshen with new files.
for f in sorted(file_list_path_in_tmp):
f_from = os.path.join(path_in_tmp, f)
f_to = os.path.join(path_in, f)
do_copy = True
if f in file_list_path_in:
if filecmp.cmp(f_from, f_to):
do_copy = False
if do_copy:
print("\tupdating: %s" % f)
shutil.copy(f_from, f_to)
'''else:
print("\tkeeping: %s" % f) # eh, not that useful'''
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
if EXAMPLE_SET_UNUSED:
print("\nUnused examples found in '%s'..." % path_examples)
for f in EXAMPLE_SET_UNUSED:
print(" %s.py" % f)
print(" %d total\n" % len(EXAMPLE_SET_UNUSED))
EXAMPLE_SET_UNUSED = EXAMPLE_SET - EXAMPLE_SET_USED
if EXAMPLE_SET_UNUSED:
print("\nUnused examples found in '%s'..." % path_examples)
for f in EXAMPLE_SET_UNUSED:
print(" %s.py" % f)
print(" %d total\n" % len(EXAMPLE_SET_UNUSED))
import sys
sys.exit()