blender.org
code.blender.org
User:Dfelinto
for
User:Dfelinto
User page
Discussion
Links
Contributions
View source
History
From BlenderWiki
Jump to:
navigation
,
search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on
wiki.blender.org
.
You can view and copy the source of this page:
=Weekly reports= http://wiki.blender.org/index.php/User:Dfelinto/Foundation =Ideas= http://wiki.blender.org/index.php/User:Dfelinto/Ideas =Stereoscopy= http://wiki.blender.org/index.php/User:Dfelinto/Stereoscopy === Git === Useful links: http://wiki.blender.org/index.php/User:Brecht#Git http://www.readncode.com/blog/how-to-do-a-git-merge-with-vim/ http://git-scm.com/book Git merge vs. rebase - http://mislav.uniqpath.com/2013/02/merge-vs-rebase/ [WARNING FOLLOWING GUIDE OUTDATED] http://wiki.blender.org/index.php/Dev:2.5/Doc/Building_Blender/Git [GITHUB is not useful for this workflow, but here some links anyways] https://help.github.com/articles/syncing-a-fork ====Getting Started==== Create a new folder, and inside this folder do the following commands. Note it will take more than 10 hours to get over with it. <source lang="bash"> # getting blender souce code git svn clone https://svn.blender.org/svnroot/bf-blender/trunk/blender blender </source> <source lang="bash"> # getting the addons git svn clone https://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts/addons addons git svn clone https://svn.blender.org/svnroot/bf-extensions/contrib/py/scripts/addons addons_contrib </source> Now the tricky part ... you actually need the addons and addons_contrib inside your blender folder. I'm copying them over and whenever I want to update them, I go and re copy them. <source lang="bash"> rsync -rv --exclude=.git addons blender/release/scripts/ rsync -rv --exclude=.git addons_contrib blender/release/scripts/ </source> It's important to make sure both folders are ignored by git. So you want to add them in the exclude file. See the ignore/exclude section next. Optionally you can also get the libraries, though honestly you can simply using svn for that. If you have the lib already somewhere else, all you need is a symlink for it. For the git folder for the library do (darwin-9.x.universal is what I use in Mac): <source lang="bash"> # getting the libraries mkdir lib; cd lib git svn clone https://svn.blender.org/svnroot/bf-blender/trunk/lib/darwin-9.x.universal darwin-9.x.universal </source> ====Git Ignore/Exclude==== This is my blender/.git/info/exclude file <source lang="bash"> /release/scripts/addons /release/scripts/addons_contrib *.pyc userconfig-*.py </source> ====Git Update==== To update the svn repository into master, and then into 'otherbranch' <source lang="bash"> cd blender git checkout master git svn rebase git checkout otherbranch git rebase master </source> From time to time you may want to update the addons as well, to do so: <source lang="bash"> cd addons git svn rebase cd ../addons_contrib git svn rebase cd ../ rsync -rv --exclude=.git addons blender/release/scripts/ rsync -rv --exclude=.git addons_contrib blender/release/scripts/ </source> And every once in a blue moon you want to update the libs: <source lang="bash"> cd lib/*/ git svn rebase </source> ====Git svn branch==== If you have a branch in the svn repository that you want to clone, you can do that after you git svn clone'd the master. http://ivanz.com/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/ 1) Define the new branch in .git/config <source lang="bash"> [svn-remote "multiview"] url = https://svn.blender.org/svnroot/bf-blender/branches/multiview fetch = :refs/remotes/git-svn-multiview </source> 2) Import the SVN branch. <source lang="bash"> cd blender git svn fetch multiview </source> Optionally you can fetch only the review where the branch was created: <source lang="bash"> svn log --stop-on-copy https://svn.blender.org/svnroot/bf-blender/branches/multiview #read the number of the first commit, in my case 57389 cd blender git svn fetch multiview -r57389 </source> 3) Hook up a local Git branch to the remote branch: <source lang="bash"> git branch --track multiview git-svn-multiview </source> 4) Checkout and update <source lang="bash"> cd blender git checkout multiview git svn rebase </source> 5) All good! The following is an example of my .git/config <source lang="bash"> [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [svn-remote "svn"] url = https://svn.blender.org/svnroot/bf-blender/trunk/blender fetch = :refs/remotes/git-svn [svn-remote "multiview"] url = https://svn.blender.org/svnroot/bf-blender/branches/multiview fetch = :refs/remotes/git-svn-multiview [branch "multiview"] remote = . merge = refs/remotes/git-svn-multiview </source> ====Git Branch==== A script to switch the active branch. <source lang="bash"> #!/bin/bash #based on 'crep' script from Campbell Barton OUT="/tmp/mktmp" git branch --list | sort > $OUT # Print text with line numbers sed = $OUT | sed 'N;s/\n/ /' echo -n "enter a number to edit > " read -e LINE if [ "$LINE" == "" ] ; then echo "nothing selected... exiting." exit 0 fi LINE=$LINE"p" # 4 -> 4p - for sed EDIT=$(cat $OUT | sed -n $LINE) # file to edit rm $OUT # Now change the branch git checkout $EDIT </source> ====Happy GIT Terminal==== (based on http://wiki.blender.org/index.php/User:Brecht#Git) "I have bash configured to show the git branch in terminal, to avoid the (for me) very common mistake of committing, merging or branching in the wrong branch." <source lang="bash"> __git_ps1 () { local b="$(git symbolic-ref HEAD 2>/dev/null)"; if [ -n "$b" ]; then printf "%s " "${b##refs/heads/}"; fi } PS1="\u \[\\033[1;90m\]\$(__git_ps1)\[\\033[0m\]\W\\$ " </source> ====Happy GIT Alias==== (based on http://wiki.blender.org/index.php/User:Brecht#Git) It requires the [http://wiki.blender.org/index.php/User:Dfelinto#Happy_GIT_Terminal __git_ps1] already to be in the .profile Note the 'gad' alias. This one I use when I want to setup a specific number of jobs (e.g. gad make -j3) or any other command I don't use too often to justify its own alias (e.g. gad ccmake). <source lang="bash"> function git_any_dir() { local root="$(git rev-parse --show-toplevel)/../release" local branch="$(__git_ps1)" local prevdir=$(pwd); if [ -d $root/$branch ]; then cd $root/$branch else cd $root/master fi $@ cd $prevdir } </source> ====Git Vim==== Utility to open vim with all the diff and cached files <source lang="bash"> #!/bin/bash cached=`git diff --name-only --cached` diff=`git diff --name-only` cd $(git rev-parse --show-toplevel) vim -p ${diff[*]} ${cached[*]} </source> ====GAM==== I had to use git am to move repositories around (see http://stackoverflow.com/questions/10220374/can-i-git-svn-rebase-to-a-certain-svn-revision-similar-to-svn-up-r ) This script is to call git am for a sequence of files (NOTE: files folder and "name" hardcoded in the script). <source lang=bash> SOURCE=/tmp/merge_patches/ gam () { for i in `seq $1 $2`; do echo "SVN-PATCH: $i" git am $SOURCE/`echo $(printf "%04d" "${i}")`*.patch echo "[next]" read next done } </source> To use I do: <source lang=bash> gam 14 19 </source> ===old stuff=== An quick exert about me from Blender Conference 2008 + updates: Dalai Felinto, who is currently living in Rio de Janeiro, Brazil, has been using Blender since the beginning of his graduate study in Architecture and Urban Studies back in 2003. His participation in the Blender Community includes a paper and a tutorial presented at the 2007 Blender Pro Brazil in Porto Alegre, an image published in a Blender magazine in Brazil, co-hosting of the first Vancouver Blender Workshop in 2008, a work presented with Mike Pan at the 2008 Blender Conference in Amsterdam, two talks at the 2009 Che Blender in Córdoba, Argentina and a number of contributions to Blender code since 2.47. His past professional experiences with Blender includes the implementation of a dome rendering mode for the Blender Game Engine sponsored by the art school SAT: Society for Arts and Technology of Montreal in 2009, a 3 month job experience as game developer and technical artist for the Entertainment Arts Research's production of a third person action thriller game (Twilight22) and a two month production as a digital artist for the Fisheries Center at the University of British Columbia, Canada, for a 7 minute long digital documentary about the life in Chesapeake Bay. He's currently involved with a marine ecosystem visualization project at the University of British Columbia in Canada using and developing the Blender Game Engine as an interactive tool. www.lenfestoceanfutures.org http://blenderecia.orgfree.com ==Tex Face :: Replacement== read about this proposal on: http://wiki.blender.org/index.php/User:Dfelinto/TexFace ==Dome Offline Rendering Thoughts== moved to: http://wiki.blender.org/index.php/User:Dfelinto/OfflineFisheyeRender ==Complement SDNA== * Notes about pointers When adding pointers as structure elements there is one more step you need to do. All pointers are stored in the Blender files with their original address. When the file is loaded, Blender needs to readdress the pointer to the new address of the element. This happens in the readfile.c. Therefore there is three functions you may need to change to set your pointer. As an example if you want to add an actuator (they are part of the object global list), you you need to edit the readfile.c in three parts: * In expand_object() do a expand_doit() * In lib_link_object() you do a newlibadr_us() * In direct_link_object() ??????? And in writefile.c you will need to write the structure for your pointer. Find the right write_function (eg write_actuators) and call properly writestruct(); For more information check the [http://www.blender.org/development/architecture/#c1237 Blender Architecture]. ==Blender Conference Architecture Round Table Minute draft== Right now I will write here the minutes of the Blender for Architecture Round Table (This still is a rough, I will clean this later) Milanov – Architecture How we can improve Blender to “make the 1st 3D Open Source application”. -a tool not only for presentation, but a project tool -3d sketchs from the beggining. -sections Precision (more than 32 bits float precision) Repetition / modules [Blender -a // playback animation] - curiosity, off-topic but awesome Offset / trim / extend cross sections Shell IGES – Nurbs format FEATURES / ISSUES: -exporter DXF – Drawing Exchange Format fbx nurbs formats (??) [.x3d .DAE (Collada)] - my addition Photo matching system (e.g. SketchUp PhotoMatch) -measuring, summed length values -uvmap, extending the current UV system for simple tasks as paint an UV based in the neighbor faces). -snapping(thanks theeth), more snaps(e.g. center, ...) -precision – render merging problems (when the distance is too small for some distances it results in imprevisible results). APPENDIX 01 – CAD Commands: (These are my personal list of most required cad commands. I created it to provide a feature request list to the project Archimedes). It's interesting to see that the only commands Blender can't do were cited in the roundtable. They are: Offset, Distance, Fillet, Trim, Extend. List: _____line _____circle =====offset _____polyline _____move _____copy _____mirror _____rotate _____scale _____explode _____match properties _____block _____break =====distance _____scale _____divide =====fillet =====trim =====extend _____arc _____stretch _____boundary (bo) _____align (al) _____draworder (dr) _____pedit (pe) _____write block (w) _____insert raster image _____paperspace ==BGE develop meeting notes== Blender Conference 2008 - 01 – Blender Game Engine future Blender Game Engine Web Plugin The web plugin was abandoned since 200????. Recently in this year we have some developers trying to ressucite it to the most diferent platforms. Until now the new plugin is working only for unix systems. - no bad level calls in 2.50 rewrite The trend (in Apricot) is to implement all Blender features (Constraints, Drivers, …) in BGE. However there is no budget, no payed BGE developer. Things are changing though. game engine as a plugin? Tree data and memory managed to Blender interface converted to BGE objects. This is fine when BGE owrk inside Blender. However outside Blender it doesn't work fine (pointers present risk in memory assignment). BGE use part of Blender code (IPO, Bone structure) licensing is an issue. Option: separate the data and the code. The game can be released as a blendfile cryptografed and the Game Player (i.e. BlenderPlayer). WebPlugin Blender Game Engine. security problem. Python problems. Differences of security levels/issues in network applications or local ones. It is not desired to associate Blender name with the risk of insecure web applications. It is needed a company willing to support the plugin development to stick on that. SandBoxing issues Blender sand boxing bad python calls A company should show progress: - Huge companies: Google, Nvidia, IBM - documentation - support maintaince / bugs, features, … It is a lot of work for the company and for the Blender Foundation. Reviewing patches developed for third parts isn't so easy (or exciting) ISSUES: trusty, capacity rely =UTF8 and complex-scripting = [http://behdad.org/text/ State of Text Rendering] [http://techessence.info/webdesign/unicode Unicode and "character encodings"] [http://techessence.info/node/60 UTF-8 and Latin-1: The Leaning Tower of Babel] ==Random Notes== * ASCII is back-supported in pretty much all the possible encodings. For example, ascii can be considered as a sub-set of UTF8. Unicode range: 0000 - 007F - ascii 0080 - 00FF - latin1 06XX - arabic FEFX - arabic presentation form utf8 can use up to 4 bytes to represent the data. "For slots 160 through 255, UTF-8 uses that number to determine how many following bytes to add in when calculating the numbered Unicode slot being referred to." [http://techessence.info/node/60] ==Bi-Directional text support == external libraries to use with freetype2: http://behdad.org/text/] (1) expand blf to support bidi (i.e. RTL) There are two problems here. One is to draw the text, and the second is to handle editing. It's impossible to implement editing of bidi without having blf drawing it properly. Thus the plan is to first address drawing and then later editing. ===harfbuzz-ng=== (email that showed up in the mailing list) I guess you can't go wrong with [http://www.freedesktop.org/wiki/Software/HarfBuzz harfbuzz-ng] on freetype2. After all, that is what's used to render text in Firefox. libass, the SSA subtitle renderer used in VLC and MPlayer, has recently started to support complex and bidi scripts using harfbuzz and fribidi on top of freetype2. That resulted in very sophisticated rendering of complex texts. Implementing that turned out to be easier than the developer had thought. [http://ssadev.blogspot.com/2011/05/getting-complex-text-layout-into-libass.html] ===Drawing Complex Scripting=== * note: even after we have bfl handling bidi we can still use the ar_to_utf.py and fa_to_utf.py scripts. they should work either way and they should bring some optimization (given that interface drawing happens all the time). ===Editing Complex Scripting=== Likely re-using part of the code from the drawing routine. ==Unifying utf8 with ascii and removing latin1== My proposal is to merge ascii and utf8 in the GHOST_System* files (they all lead to GHOST_EventKey.h). Also any input (keys, clipboard, ...) should be converted to utf8. (for Text Editor convert to utf8? or pops up an warning: File with non-supported encoding. [ ] cancel opening file [ ] convert file to utf8) The one part we will still need latin1 is the filepath checking. Specially in windows we have a lot of filepaths using non-utf8 encoding (latin1 seems to be the default there). We would need to convert the typed in path to latin1 as a fallback when the utf8 typed path doesn't exist. Or we find native OS calls to handle that. =Miscellaneous Programming Stuff= Campbell Barton great collection of scripts - [http://wiki.blender.org/index.php/User:Ideasman42] I use crep all the time. ===building and piping=== python2.7 scons/scons.py -j1 2>&1 | tee out.txt ===gcc=== * cambo: http://www.pasteall.org/46376/bash * jens: http://www.pasteall.org/46377 * ton: http://www.pasteall.org/46422 ===svn tips=== [b]make a file executable[/b]: svn propset svn:executable ON [filename] [b]make externals[/b]: svn propset svn:externals -F [list of externalsfilename] [b]commit with log inline[/b]: svn commit --message="log message can be multi-line" ===vim tips=== [b]ga[/b]: reads a unicode char (the hexacode can be used with "\uXXXX" in python. [b]Ctrl+V uXXXX[/b]: insert a unicode in insert mode ===pydocs update=== <source lang=bash> #/bin/bash # my blender source is in ~/blender/bf and my release build in ~/blender/release # needs sphinx first: #sudo easy_install -U Sphinx cd ~/blender/bf # apply bpy context patch patch -p0 <<END Index: doc/python_api/sphinx_doc_gen.py =================================================================== --- doc/python_api/sphinx_doc_gen.py (revision 43647) +++ doc/python_api/sphinx_doc_gen.py (working copy) @@ -61,7 +61,9 @@ if 1: # full build EXCLUDE_INFO_DOCS = False - EXCLUDE_MODULES = () + EXCLUDE_MODULES = ( + "bpy.context" + ) FILTER_BPY_TYPES = None FILTER_BPY_OPS = None END # generate the raw files ~/blender/release/bin/blender.app/Contents/MacOS/blender --background -noaudio --python doc/python_api/sphinx_doc_gen.py # generate the html files cd doc/python_api sphinx-build sphinx-in sphinx-out # launch the webbrowser open sphinx-out/contents.html # revert source svn revert sphinx_doc_gen.py </source> === ddiff=== Sometimes I need to check the changes in a branch against the original code in trunk. `svn diff` will only tell me part of the story (what I changed from last commit to the branch). `ddiff Ketsji/KX_Dome.cpp` will run a diff -u comparing the branch KX_Dome.cpp with trunk's one. It assumes you have blender code in ~/blender/bf It can work with meld as well, but in OSX I can't get meld to work so whatever :) <source lang=python> #!/usr/bin/python import sys, os HOME = os.getenv('USERPROFILE') or os.getenv('HOME') BLENDERSOURCE = os.path.abspath(os.path.join(HOME, 'blender', 'bf')) file = sys.argv[1] basepath = os.path.dirname(file) filepath = os.path.basename(file) path = os.popen('cat %s | grep branches' % (os.path.join(basepath, '.svn', 'all-wcprops'))).read().split()[0] path_parts = path.split(os.sep) branch_id = path_parts.index('branches') trunk_path = os.sep.join(str(n) for n in path_parts[branch_id+2:]) trunk_path = os.path.join(BLENDERSOURCE, trunk_path, filepath) # ignore the ID line in Blender code (the $id:....$) # it may need a better regex but this works for now svn_id_regex = '[$]Id:' os.system("diff -u --ignore-matching-lines=%s \"%s\" \"%s\"" % (svn_id_regex, trunk_path, file)) </source> ===Arabic to UTF8=== Script based on the original take by Yousef Harfoush - http://sourceforge.net/p/batp/code. It takes an arabic po file file and flip and convert the characters to the utf8 char corresponding to the right shape for its position. It runs with Python 3.2 `python3.2 ar.po [flipped_ar.do]` <source lang=python> #coding: utf-8 import sys import os alfmd = ["ﺁ","ﺁ","ﺂ","ﺂ"] alfhz = ["ﺃ","ﺃ","ﺄ","ﺄ"] wowhz = ["ﺅ","ﺅ","ﺆ","ﺆ"] alfxr = ["ﺇ","ﺇ","ﺈ","ﺈ"] hamzk = ["ﺉ","ﺋ","ﺌ","ﺊ"] alfff = ["ﺍ","ﺍ","ﺎ","ﺎ"] baaaa = ["ﺏ","ﺑ","ﺒ","ﺐ"] tamrb = ["ﺓ","ﺓ","ﺔ","ﺔ"] taaaa = ["ﺕ","ﺗ","ﺘ","ﺖ"] thaaa = ["ﺙ","ﺛ","ﺜ","ﺚ"] geeem = ["ﺝ","ﺟ","ﺠ","ﺞ"] haaaa = ["ﺡ","ﺣ","ﺤ","ﺢ"] khaaa = ["ﺥ","ﺧ","ﺨ","ﺦ"] daaal = ["ﺩ","ﺩ","ﺪ","ﺪ"] thaal = ["ﺫ","ﺫ","ﺬ","ﺬ"] raaaa = ["ﺭ","ﺭ","ﺮ","ﺮ"] zaaai = ["ﺯ","ﺯ","ﺰ","ﺰ"] seeen = ["ﺱ","ﺳ","ﺴ","ﺲ"] sheen = ["ﺵ","ﺷ","ﺸ","ﺶ"] saaad = ["ﺹ","ﺻ","ﺼ","ﺺ"] daaad = ["ﺽ","ﺿ","ﻀ","ﺾ"] taaah = ["ﻁ","ﻃ","ﻄ","ﻂ"] daaah = ["ﻅ","ﻇ","ﻈ","ﻆ"] aayen = ["ﻉ","ﻋ","ﻌ","ﻊ"] gayen = ["ﻍ","ﻏ","ﻐ","ﻎ"] faaaa = ["ﻑ","ﻓ","ﻔ","ﻒ"] qaaaf = ["ﻕ","ﻗ","ﻘ","ﻖ"] kaaaf = ["ﻙ","ﻛ","ﻜ","ﻚ"] laaam = ["ﻝ","ﻟ","ﻠ","ﻞ"] meeem = ["ﻡ","ﻣ","ﻤ","ﻢ"] nooon = ["ﻥ","ﻧ","ﻨ","ﻦ"] hhhhh = ["ﻩ","ﻫ","ﻬ","ﻪ"] wowww = ["ﻭ","ﻭ","ﻮ","ﻮ"] yaamd = ["ﻯ","ﻯ","ﻰ","ﻰ"] yaaaa = ["ﻱ","ﻳ","ﻴ","ﻲ"] laamd = ["ﻵ","ﻵ","ﻶ","ﻶ"] laahz = ["ﻷ","ﻷ","ﻸ","ﻸ"] laaxr = ["ﻹ","ﻹ","ﻺ","ﻺ"] laaaa = ["ﻻ","ﻻ","ﻼ","ﻼ"] numbers ="0123456789٠١٢٣٤٥٦٧٨٩"#defining numbers unicodec ="ﺁﺁﺂﺂﺃﺃﺄﺄﺅﺅﺆﺆﺇﺇﺈﺈﺉﺋﺌﺊﺍﺍﺎﺎﺏﺑﺒﺐﺓﺓﺔﺔﺕﺗﺘﺖﺙﺛﺜﺚﺝﺟﺠﺞﺡﺣﺤﺢﺥﺧﺨﺦﺩﺩﺪﺪﺫﺫﺬﺬﺭﺭﺮﺮﺯﺯﺰﺰﺱﺳﺴﺲﺵﺷﺸﺶﺹﺻﺼﺺﺽﺿﻀﺾﻁﻃﻄﻂﻅﻇﻈﻆﻉﻋﻌﻊﻍﻏﻐﻎﻑﻓﻔﻒﻕﻗﻘﻖﻙﻛﻜﻚﻝﻟﻠﻞﻡﻣﻤﻢﻥﻧﻨﻦﻩﻫﻬﻪﻭﻭﻮﻮﻯﻯﻰﻰﻱﻳﻴﻲﻵﻵﻶﻶﻷﻷﻸﻸﻹﻹﻺﻺﻻﻻﻼﻼ"#defining arabic unicodec chars left = "ـئظشسيبلتنمكطضصثقفغعهخحج" #defining letters that can connect from the left right = "ـئؤرلالآىآةوزظشسيبللأاأتنمكطضصثقفغعهخحجدذلإإ"#defining letters that can connect from the right arabic ="ًٌٍَُِّْْئءؤرلاىةوزظشسيبلاتنمكطضصثقفغعهخحجدذْلآآلأأـلإإ،؟"#defining all arabic letters + harakat + symbols harakat ="ًٌٍَُِّْْ" #defining the harakat sym ="ًٌٍَُِّـ.،؟ @#$%^&*-+|\/=~(){}ْ," #defining other symbols def ProcessInput(input): '''main function, the code is not self-explanatory. It requires understanding of arabic alphabet (which is pretty cool by the way)''' phrase = "" x=list(input) ln=len(x) #process each letter, submit it to tests and then add it to the output string # we can't do a for loop because we need to change 'g' inside the loop g = 0 while g < ln: b=a=1 #ignoring/discarding the harakat # see how many chars I need to skip to get the next # non-harakat char in the left (a) or the right(b) while g-b >= 0 and x[g-b] in harakat: b+=1 while g+a < ln and x[g+a] in harakat: a+=1 # if char can connect to left and there is a char after # and it can connect to the right: if x[g] in left and g+a < ln and x[g+a] in right: if x[g] in right and g-b >= 0 and x[g-b] in left: pos = 2 #midle else: pos = 1 #initial else: if x[g] in right and g-b >= 0 and x[g-b] in left: pos = 3 #final else: pos = 0 #isolated # find what char to aggregate to the phrase based on the input and its # position in the word. chr = "" if x[g]=="\n": {} #if this char is a new line, go to add new line def elif x[g]=="\r": {} #if this char is carriage return, skip it. elif x[g]=="{": chr="}" #dealing with parenthesis elif x[g]=="}": chr="{" elif x[g]=="(": chr=")" elif x[g]==")": chr="(" elif x[g]=="ء": chr="ﺀ" elif x[g]=="آ": chr=alfmd[pos] #dealing with letters, output each letter with its right position elif x[g]=="أ": chr=alfhz[pos] elif x[g]=="ؤ": chr=wowhz[pos] elif x[g]=="إ": chr=alfxr[pos] elif x[g]=="ئ": chr=hamzk[pos] elif x[g]=="ا": chr=alfff[pos] elif x[g]=="ب": chr=baaaa[pos] elif x[g]=="ة": chr=tamrb[pos] elif x[g]=="ت": chr=taaaa[pos] elif x[g]=="ث": chr=thaaa[pos] elif x[g]=="ج": chr=geeem[pos] elif x[g]=="ح": chr=haaaa[pos] elif x[g]=="خ": chr=khaaa[pos] elif x[g]=="د": chr=daaal[pos] elif x[g]=="ذ": chr=thaal[pos] elif x[g]=="ر": chr=raaaa[pos] elif x[g]=="ز": chr=zaaai[pos] elif x[g]=="س": chr=seeen[pos] elif x[g]=="ش": chr=sheen[pos] elif x[g]=="ص": chr=saaad[pos] elif x[g]=="ض": chr=daaad[pos] elif x[g]=="ط": chr=taaah[pos] elif x[g]=="ظ": chr=daaah[pos] elif x[g]=="ع": chr=aayen[pos] elif x[g]=="غ": chr=gayen[pos] elif x[g]=="ف": chr=faaaa[pos] elif x[g]=="ق": chr=qaaaf[pos] elif x[g]=="ك": chr=kaaaf[pos] elif x[g]=="ل": #dealing with (la combination g=g+1 if ln == g: g=g-1 chr=laaam[pos] elif x[g]=="ا": chr=laaaa[pos] elif x[g]=="أ": chr=laahz[pos] elif x[g]=="إ": chr=laaxr[pos] elif x[g]=="آ": chr=laamd[pos] else: g=g-1 chr=laaam[pos] elif x[g]=="م": chr=meeem[pos] elif x[g]=="ن": chr=nooon[pos] elif x[g]=="ه": chr=hhhhh[pos] elif x[g]=="و": chr=wowww[pos] elif x[g]=="ى": chr=yaamd[pos] elif x[g]=="ي": chr=yaaaa[pos] elif x[g]=="لآ": chr=laamd[pos] elif x[g]=="لأ": chr=laahz[pos] elif x[g]=="لإ": chr=laaxr[pos] elif x[g]=="لا": chr=laaaa[pos] elif x[g] in sym: chr=x[g] #if the char is a symbol, add it elif x[g] in unicodec: chr=x[g] #if the char is an arabic reversed letter, reverse it back! # advance to the next char g += 1 # add the char before the previous one hrase = chr+phrase return phrase def Start(fileR, fileW): '''open the .po file and do a special reverse in the msgstr lines''' fileR = open(fileR, "r",-1, "utf-8") fileW = open(fileW, "w",-1, "utf-8") inside_msgstr = False inside_header = True for line in fileR: if inside_header: fileW.write(line) if line == "\n": inside_header = False else: if line[:6] == ("msgstr"): word = line.split("\"") strng = word[1] rslt = "" if strng: rslt = str(ProcessInput(strng)) fileW.write("msgstr \"" + rslt + "\"\n") inside_msgstr = True elif inside_msgstr: word = line.split("\"") if len(word) > 1: strng = word[1] rslt = str(ProcessInput(strng)) fileW.write("\"" + rslt + "\"\n") else: fileW.write(line) inside_msgstr = False else: fileW.write(line) inside_msgstr = False fileR.close() fileW.close() if __name__ == "__main__": #argument parsing if len(sys.argv) != 2 and len(sys.argv) != 3: print("Error: Missing arguments. Use: `python arabic_to_utf.py ar.po [ar_done.po]`") exit() file_input=os.path.abspath(sys.argv[1]) if file_input[-3:] != ".po": print("Error: Wrong file format. Use: `python arabic_to_utf.py ar.po [ar_done.po]`") exit() # the last parameter is optional if len(sys.argv) == 2: file_output = "%s_done.po" % file_input[:-3] else: file_output = os.path.abspath(sys.argv[2]) # parse the file Start(file_input, file_output) </source> ===Windows Blender Build 1=== Batch script to update and build Blender in Windows with MSVC+Scons. You need Python installed and matching the architecture you are to build for (i.e. Python32 bits for Windows32 bits and Python64 for Windows 64). As of the time of writing Python 2.XX is the only supported series. You also need SlikSvn for your version of Python (it's a Python SVN client, really nice) To build for 64 bits you need to use those lines instead of the ones in the script: Set USERCONFIG=%BLENDER%\user-config-64.py call %MSVC% amd64 <source lang=winbatch> :requires SlikSvn and MSVC 2008 with command prompt @echo off Setlocal Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" Set SVN="C:\Program Files\SlikSvn\bin\svn.exe" Set PYTHON="C:\Python27\python.exe" Set BLENDER=C:\Blender\bf Set USERCONFIG=%BLENDER%\user-config.py REM the number of processors to use to render Set NUMCPU=8 echo Launching MSVC call %MSVC% x86 chdir %BLENDER% echo Updating Blender %SVN% --accept postpone update echo Removing old Blender build rmdir /s/q "..\install_fun" echo Building Blender %PYTHON% scons\scons.py BF_CONFIG=%USERCONFIG% -j%NUMCPU% echo Congratulations for updating Blender :exit pause </source> ===Windows Blender Build 2: build + update internal SVN=== This script is a .bat file to update Blender, build it, and update (but not commit) my internal production svn. It requires MSVC, python (2.6 or 2.7), SlikSVN. The paths are defined in the first lines of the script. CUPCAKE is my internal svn repository. Also the number of threads to use (8) is hardcoded after the -j argument in the scons line. <source lang=winbatch> :requires SlikSvn and MSVC 2008 with command prompt @echo off Setlocal Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" Set SVN="C:\Program Files\SlikSvn\bin\svn.exe" Set PYTHON="C:\Python26\python.exe" Set BLENDER=C:\Blender\BF_25\bf Set USERCONFIG=%BLENDER%\user-config-64.py REM the number of processors to use to render Set NUMCPU=8 Set CUPCAKE=C:\CupCake Set CUPCAKEBINARY=%CUPCAKE%\Blender echo Launching MSVC call %MSVC% amd64 chdir %BLENDER% REM HACK goto noupdate echo Updating Blender %SVN% --accept postpone update set INPUT= set /P INPUT=Do you want to proceed? [y/n] %=% if "%INPUT%"=="n" goto exit if "%INPUT%"=="i" goto install :noupdate echo Removing old Blender build rmdir /s/q "..\install" echo Building Blender %PYTHON% scons\scons.py BF_CONFIG=%USERCONFIG% -j%NUMCPU% :install echo Copying build files to svn folder %SVN% revert --depth infinity %CUPCAKEBINARY% rmdir /s/q %CUPCAKEBINARY% mkdir %CUPCAKEBINARY% xcopy /y/s/q %BLENDER%\..\install\blender25-win64-vc %CUPCAKEBINARY% set INPUT= set /P INPUT=Do you want to update your local svn? [y/n] %=% if "%INPUT%"=="n" goto exit echo Updating svn folder %SVN% add %CUPCAKEBINARY% echo Congratulations for updating Blender :exit pause </source> ===Windows Blender Build 3: build + random splash screen=== This script is a .bat file to update Blender and build Blender with a different Splash Screen every time. It requires MSVC, python (2.6 or 2.7), SlikSVN. Splash screens can be generated with the datatoc.py script present in Blender source code. I'm actually using a patched version of Blender's datatoc.py to generate datatoc for all images in a folder. <source lang=winbatch> :requires SlikSvn and MSVC 2008 with command prompt @echo off Setlocal REM general folder settings Set MSVC="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" Set SVN="C:\Program Files\SlikSvn\bin\svn.exe" Set PYTHON="C:\Python26\python.exe" Set BLENDER=C:\Blender\bf Set USERCONFIG=%BLENDER%\user-config-64.py REM folder with splash screens converted with datatoc.py Set SPLASHFOLDER=C:\Blender\splashes\datatoc REM the number of processors to use to render Set NUMCPU=8 :: ::::::::::::::::::::::::::::::::::::::::::::::::::: :: :: That should be all, no need to setup anything else :: ::::::::::::::::::::::::::::::::::::::::::::::::::: :: echo Launching MSVC call %MSVC% amd64 :: Do you want to update the source? set INPUT= set /P INPUT=Do you want to update Blender? [y/n] %=% if "%INPUT%"=="n" goto install :svnupdate chdir %BLENDER% echo Updating Blender %SVN% --accept postpone update set INPUT= set /P INPUT=Do you want to proceed? [y/n] %=% if "%INPUT%"=="n" goto exit if "%INPUT%"=="i" goto install :install :: Replace the Splash Screen chdir %BLENDER% echo Replacing the Splash Screen set count=0 set x=0 setlocal enabledelayedexpansion ::Put all the files into a pseudo-array prefixed with "PIC_" for /r "%SPLASHFOLDER%" %%a in (*.png.c) do ( set PIC_!count!=%%~a set /a count+=1 ) REM Use the 'modulo' function to get a usable value from system variable %random% set /a x="%RANDOM% %% count" REM Pull the relevant item out of the "PIC_" 'array' set chosen=!PIC_%x%! echo: New Splash Screen :: %chosen:~0,-2% Set BLENDERSPLASH=%BLENDER%\source\blender\editors\datafiles\splash.png.c copy /y "%chosen%" "%BLENDERSPLASH%" @echo off :: Cleaning up the installation directory echo Removing old Blender build rmdir /s/q "..\install" echo Building Blender %PYTHON% scons\scons.py BF_CONFIG=%USERCONFIG% -j%NUMCPU% echo Congratulations for updating Blender with a fantastic new Splash Screen ;) :exit pause </source> Patched datatoc.py to facilitate creating multiple splash screens from a folder. <source lang=python> #!/usr/bin/python # -*- coding: utf-8 -*- # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2009 Blender Foundation. # All rights reserved. # # # ***** END GPL LICENCE BLOCK ***** # <pep8 compliant> import sys import os def createDatatoc(filename): try: fpin = open(filename, "rb") except: sys.stdout.write("Unable to open input %s\n" % sys.argv[1]) sys.stdout.write("Trying folder now%s\n" % sys.argv[1]) sys.exit(1) fpin.seek(0, os.SEEK_END) size = fpin.tell() fpin.seek(0) if filename[0:2] == "." + os.sep: filename = filename[2:] cname = filename + ".c" sys.stdout.write("Making C file <%s>\n" % cname) filename = filename.split("/")[-1].split("\\")[-1] filename = filename.replace(".", "_") sys.stdout.write(str(size)) sys.stdout.write("\n") try: fpout = open(cname, "w") except: sys.stdout.write("Unable to open output %s\n" % cname) sys.exit(1) fpout.write("/* DataToC output of file <%s> */\n\n" % filename) fpout.write("int datatoc_%s_size= %d;\n" % ("splash_png", size)) fpout.write("char datatoc_%s[]= {\n" % "splash_png") while size > 0: size -= 1 if size % 32 == 31: fpout.write("\n") fpout.write("%3d," % ord(fpin.read(1))) fpout.write("\n 0};\n\n") fpin.close() fpout.close() if __name__ == '__main__': if len(sys.argv) < 2: sys.stdout.write("Usage: datatoc <data_file>\n") sys.exit(1) filename = sys.argv[1] if not os.path.isdir(filename): createDatatoc(filename) else: for file in os.listdir(filename): if os.path.isdir(file): continue createDatatoc(file) </source> ===building bpy for OSX=== Blenderplayer has to be built with the Framework Python (WITH_PYTHON_FRAMEWORK) bpy.so has to be built independently (WITH_PYTHON_MODULE) This works fine, however the user has to install Python in her Mac. To make this portable you need to change the linkage from the Frameworks to a local folder. I'm still struggling with it, so for now I'll only list the commands. Patch for CMake: ========== http://www.pasteall.org/39454/diff To change the linkage: ============== install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.2/Python @loader_path/2.63/Frameworks/Python bpy.so To check the linkage: ============= otool -L bpy.so To change the id: =========== install_name_tool -id Python Python jensverwiebe: but not static, i bundle the framework, static gives again thread error, but no prob [1:17pm] jensverwiebe: http://www.jensverwiebe.de/Other/dalai_pby_test.zip [1:17pm] jensverwiebe: the 2.63 folder must be beside .so [1:21pm] jensverwiebe: how it works: [1:21pm] jensverwiebe: build bpy.so as setup in cmake against py framework [1:22pm] jensverwiebe: add from lib the modules to the 2.63 folder + the framework lib out of framework Bonus: lipo -info foo.a lipo just specialized on architecture handling: glue, thin, extract, show ... ===OSL=== /bjam -j8 toolset=darwin link=static cxxflags='-fvisibility=hidden -fvisibility-inlines-hidden -fpic' threading=multi architecture=x86 address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 stage install project-config.jam after the ./boostrap run bison -dv -p osl -o oslgram.cpp oslgram.y ===Python Debug=== PyC_ObSpit ==Bash== Rename all 0001Right.jpg images to 0001_R,jpg <source lang="bash"> for i in *Right.jpg; do j=`echo $i | sed 's/Right/_R/g'`; mv $i $j; done </source> Create MultiView OpenEXR files: <source lang="bash"> for L in OpenEXR_Left/*; do R=`echo $L | sed 's/_L\./_R./g' | sed 's/Left/Right/g'`; MV=`echo $L | sed 's/_Left/_MultiView/g' | sed 's/_L\././g'`; exrmultiview left $L right $R $MV; done </source> Reverse array and increase and copy files: <source lang="bash"> array=();for i in *;do array=( "$i" "${array[@]}");done; c=1; for i in ${array[@]}; do k="../preview_right_reverse/"`echo $(printf "%.4d" "$c")`".png";c=`echo $(($c+1))`; echo "cp "$i" "$k""; cp `echo "$i"` `echo "$k"`;done </source> Rename batch: <source lang="bash"> for i in `seq 4 62`; do j=`echo $(printf "%02d" "$((i-2))")`;mv Fig04-`echo $(printf "%02d" "$i")`.tif Fig04-$j.tif;done </source> Convert all files to tif: <source lang="bash"> for i in *.png; do j=`echo $i | sed 's/png/tif/g'`; convert $i $j; done </source> Remove duplicates: <source lang="bash"> cat MYFILES | sort -u > MY_NEWFILES </source> Convert tabs to space: <source lang="bash"> for i in *.py; do perl -e '($_ = join "",<>) =~ s/(\t)/ /g; print;' -i < $i > /tmp/abc; mv /tmp/abc $i; done </source> Convert tabs to space 2: <source lang="bash"> for i in `find * -name *.py`; do expand $i > /tmp/abc; mv /tmp/abc $i; done </source> Remove trailing spaces: <source lang="bash"> for i in `find * -name *.py`; do sed -i '' -e's/[[:space:]]*$//' $i; done </source> Split a branch into individual commits per file: <source lang="bash"> for i in `git diff origin/master origin/pep8ized --name-only`; do git show origin/pep8ized:$i > $i; git add $i; git commit -m $i;done </source> Convert all files from python 2 to python 3 <source lang="bash"> for i in `find . -name "*.py" | grep -v venv`; do 2to3-3.5 -w $i; done</source> </source> Rename Frame-1, Frame-3, Frame-5, ... to Frame-1, Frame-2, Frame-3, ... <source lang="bash"> mkdir ../reordered;count=1;for i in `ls -tr`; do newname="Frame-${count}.jpg";cp -v "$i" ../reordered/"$newname";count=$((count+1)); done </source> ==SVN== rebase an svn folder: <source lang="bash"> for f in `find . -name '*' -print|grep entries`; do sed -i '' -e's/https:\/\/iml-gfx/http:\/\/mike.ecopath.org/' $f; done </source> create external: <source lang="bash"> svn propset svn:externals 'database http://www.dalaifelinto.com/svn/einteriores-database' . </source> ==Regex== replace all instances of TRUE by 1 not including ifdef of _TRUE <source lang="bash"> for i in `cat FILES`;do sed -i '/ifdef\ /b; /_TRUE/b; s/TRUE/1/g' $i;done </source> swap the first with the second field in a csv file <source lang="bash"> :s/^\([^,]*\),\([^,]*\)/\2,\1 </source> change python code for my files <source lang="bash"> for f in `cat ~/tmp/FILES`; do sed -i 's/os.path.join\((.*)\)/"\/".join(\1)/' $f; done </source> ==FFmpeg== '''RTSP Server''' <source lang="bash">vlc -vvv your_file.avi --sout "#rtp{dst=dest_adress,port=1234,sdp=rtsp://your_ip_adress:8080/test.sdp}"</source> '''RTSP Client''' <source lang="bash">vlc -vvv rtsp://your_ip_address:8080/test.sdp</source> '''RTSP Building Instructions''' <source lang="bash">--enable-network --enable-protocol=tcp --enable-demuxer=rtsp --enable-decoder=h264</source> ==Documentation== '''Update my copy of manual''': rsync -rvu --exclude=.doctrees html/ dfelinto@dalaifelinto.com:/var/www/blender-manual/ '''To start the RST server''': instantRst -f /home/guest/blender/git/blender-manual/manual/render/workflows/multiview.rst -b google-chrome ==Linux VM memory issues== Checks current swap space by running free command (It must be around 10GB.). Checks the swap partition <source lang="bash"> sudo fdisk -l /dev/hda8 none swap sw 0 0 </source> Make swap space and enable it. <source lang="bash"> sudo swapoff -a sudo /sbin/mkswap /dev/hda8 sudo swapon -a </source> If your swap disk size is not enough you would like to create swap file and use it. Create swap file. <source lang="bash"> sudo fallocate -l 10g /mnt/10GB.swap sudo chmod 600 /mnt/10GB.swap </source> OR <source lang="bash"> sudo dd if=/dev/zero of=/mnt/10GB.swap bs=1024 count=10485760 sudo chmod 600 /mnt/10GB.swap </source> Mount swap file. <source lang="bash"> sudo mkswap /mnt/10GB.swap </source> Enable swap file. <source lang="bash"> sudo swapon /mnt/10GB.swap </source> ==SVN Frontend for GIT== http://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/ https://github.com/bozaro/git-as-svn ==ASAN== Add the following in the Tools > Options > Startup <source lang="bash"> break __asan_report_error break AsanCheckFailed break __ubsan_handle_out_of_bounds </source> ==Totfree== Unfreed memory: uncomment //#define DEBUG_BACKTRACE in mallocn_guarded_impl.c, and make a debug build ==Cleanup Files== <source lang="bash">find * -name *.blend1 | xargs -I{} cp "{}"</source> ==SED== <source lang="bash">sed -i -e's/\(static int .*_shader.*GPUMaterial \*mat, bNode \*\)UNUSED.node./\1node/' $FILENAME</source> <source lang="bash">sed -i -e's/\(GPU_stack_link(mat, \)"/\1node, "/' $FILENAME</source> =Image Magick= <source lang="bash">convert EAST_0001_R.jpg WEST_0001_R.jpg ZENITH_0001_R.jpg NADIR_0001_R.jpg NORTH_0001_R.jpg SOUTH_0001_R.jpg EAST_0001_L.jpg WEST_0001_L.jpg ZENITH_0001_L.jpg NADIR_0001_L.jpg NORTH_0001_L.jpg SOUTH_0001_L.jpg +append output.jpg</source> =MEM Debug Blender= <source lang="diff"> diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c index 76b7e072321..387e9d419d2 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.c +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c @@ -52,13 +52,13 @@ * but this introduces some overhead to memory header and makes * things slower a bit, so better to keep disabled by default */ -//#define DEBUG_MEMDUPLINAME +#define DEBUG_MEMDUPLINAME /* Only for debugging: * lets you count the allocations so as to find the allocator of unfreed memory * in situations where the leak is predictable */ -//#define DEBUG_MEMCOUNTER +#define DEBUG_MEMCOUNTER /* Only for debugging: * defining DEBUG_THREADS will enable check whether memory manager @@ -76,7 +76,7 @@ * memory block was allocated and print this trace for all * unfreed blocks. */ -//#define DEBUG_BACKTRACE +#define DEBUG_BACKTRACE #ifdef DEBUG_BACKTRACE # define BACKTRACE_SIZE 100 @@ -84,7 +84,7 @@ #ifdef DEBUG_MEMCOUNTER /* set this to the value that isn't being freed */ -# define DEBUG_MEMCOUNTER_ERROR_VAL 0 +# define DEBUG_MEMCOUNTER_ERROR_VAL 13029 static int _mallocn_count = 0; /* breakpoint here */ </source>
Return to
User:Dfelinto
.
User:Dfelinto
Unversioned
Main Page
Blender Development
Blender 2.6
User Manual
Tutorials
Books
Scripts
2.72 Python API
(external link)
Blender Development
Blender 2.5
2.59 Python API
(external link)
Blender Development
Blender 2.4
User Manual
Tutorials
Books
Scripts
2.49 Python API
(external link)
Blender Development