Merge pull request #365 from erwincoumans/master
more finishing touches for Bullet 2.83 release
This commit is contained in:
780
Doxyfile
Normal file
780
Doxyfile
Normal file
@@ -0,0 +1,780 @@
|
||||
# Doxyfile 1.2.4
|
||||
|
||||
# This file describes the settings to be used by doxygen for a project
|
||||
#
|
||||
# All text after a hash (#) is considered a comment and will be ignored
|
||||
# The format is:
|
||||
# TAG = value [value, ...]
|
||||
# For lists items can also be appended using:
|
||||
# TAG += value [value, ...]
|
||||
# Values that contain spaces should be placed between quotes (" ")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
|
||||
# by quotes) that should identify the project.
|
||||
PROJECT_NAME = "Bullet Collision Detection & Physics Library"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER =
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY =
|
||||
|
||||
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
|
||||
# documentation generated by doxygen is written. Doxygen will use this
|
||||
# information to generate all constant output in the proper language.
|
||||
# The default language is English, other supported languages are:
|
||||
# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese,
|
||||
# Korean, Hungarian, Norwegian, Spanish, Romanian, Russian, Croatian,
|
||||
# Polish, Portuguese and Slovene.
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
# Private class members and static file members will be hidden unless
|
||||
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_PRIVATE = YES
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||
# undocumented members of documented classes, files or namespaces.
|
||||
# If set to NO (the default) these members will be included in the
|
||||
# various overviews, but no documentation section is generated.
|
||||
# This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy.
|
||||
# If set to NO (the default) these class will be included in the various
|
||||
# overviews. This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
|
||||
# include brief member descriptions after the members that are listed in
|
||||
# the file and class documentation (similar to JavaDoc).
|
||||
# Set to NO to disable this.
|
||||
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
|
||||
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
|
||||
# the brief description of a member or function before the detailed description.
|
||||
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
|
||||
# brief descriptions will be completely suppressed.
|
||||
|
||||
REPEAT_BRIEF = YES
|
||||
|
||||
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
|
||||
# Doxygen will generate a detailed section even if there is only a brief
|
||||
# description.
|
||||
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
|
||||
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
|
||||
# path before files name in the file list and in the header files. If set
|
||||
# to NO the shortest path that makes the file name unique will be used.
|
||||
|
||||
FULL_PATH_NAMES = NO
|
||||
|
||||
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
|
||||
# can be used to strip a user defined part of the path. Stripping is
|
||||
# only done if one of the specified strings matches the left-hand part of
|
||||
# the path. It is allowed to use relative paths in the argument list.
|
||||
|
||||
STRIP_FROM_PATH =
|
||||
|
||||
# The INTERNAL_DOCS tag determines if documentation
|
||||
# that is typed after a \internal command is included. If the tag is set
|
||||
# to NO (the default) then the documentation will be excluded.
|
||||
# Set it to YES to include the internal documentation.
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
|
||||
# generate a class diagram (in Html and LaTeX) for classes with base or
|
||||
# super classes. Setting the tag to NO turns the diagrams off.
|
||||
|
||||
CLASS_DIAGRAMS = YES
|
||||
|
||||
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
|
||||
# be generated. Documented entities will be cross-referenced with these sources.
|
||||
|
||||
SOURCE_BROWSER = YES
|
||||
|
||||
# Setting the INLINE_SOURCES tag to YES will include the body
|
||||
# of functions and classes directly in the documentation.
|
||||
|
||||
INLINE_SOURCES = NO
|
||||
|
||||
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
|
||||
# doxygen to hide any special comment blocks from generated source code
|
||||
# fragments. Normal C and C++ comments will always remain visible.
|
||||
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
|
||||
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
|
||||
# file names in lower case letters. If set to YES upper case letters are also
|
||||
# allowed. This is useful if you have classes or files whose names only differ
|
||||
# in case and if your file system supports case sensitive file names. Windows
|
||||
# users are adviced to set this option to NO.
|
||||
|
||||
CASE_SENSE_NAMES = YES
|
||||
|
||||
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
|
||||
# will show members with their full class and namespace scopes in the
|
||||
# documentation. If set to YES the scope will be hidden.
|
||||
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
|
||||
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
|
||||
# will generate a verbatim copy of the header file for each class for
|
||||
# which an include is specified. Set to NO to disable this.
|
||||
|
||||
VERBATIM_HEADERS = YES
|
||||
|
||||
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
|
||||
# will put list of the files that are included by a file in the documentation
|
||||
# of that file.
|
||||
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
|
||||
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
|
||||
# will interpret the first line (until the first dot) of a JavaDoc-style
|
||||
# comment as the brief description. If set to NO, the JavaDoc
|
||||
# comments will behave just like the Qt-style comments (thus requiring an
|
||||
# explict @brief command for a brief description.
|
||||
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
|
||||
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
|
||||
# member inherits the documentation from any documented member that it
|
||||
# reimplements.
|
||||
|
||||
INHERIT_DOCS = YES
|
||||
|
||||
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
|
||||
# is inserted in the documentation for inline members.
|
||||
|
||||
INLINE_INFO = YES
|
||||
|
||||
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
|
||||
# will sort the (detailed) documentation of file and class members
|
||||
# alphabetically by member name. If set to NO the members will appear in
|
||||
# declaration order.
|
||||
|
||||
SORT_MEMBER_DOCS = YES
|
||||
|
||||
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
|
||||
# tag is set to YES, then doxygen will reuse the documentation of the first
|
||||
# member in the group (if any) for the other members of the group. By default
|
||||
# all members of a group must be documented explicitly.
|
||||
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
|
||||
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
|
||||
# Doxygen uses this value to replace tabs by spaces in code fragments.
|
||||
|
||||
TAB_SIZE = 8
|
||||
|
||||
# The ENABLE_SECTIONS tag can be used to enable conditional
|
||||
# documentation sections, marked by \if sectionname ... \endif.
|
||||
|
||||
ENABLED_SECTIONS =
|
||||
|
||||
# The GENERATE_TODOLIST tag can be used to enable (YES) or
|
||||
# disable (NO) the todo list. This list is created by putting \todo
|
||||
# commands in the documentation.
|
||||
|
||||
GENERATE_TODOLIST = NO
|
||||
|
||||
# The GENERATE_TESTLIST tag can be used to enable (YES) or
|
||||
# disable (NO) the test list. This list is created by putting \test
|
||||
# commands in the documentation.
|
||||
|
||||
GENERATE_TESTLIST = YES
|
||||
|
||||
# This tag can be used to specify a number of aliases that acts
|
||||
# as commands in the documentation. An alias has the form "name=value".
|
||||
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
|
||||
# put the command \sideeffect (or @sideeffect) in the documentation, which
|
||||
# will result in a user defined paragraph with heading "Side Effects:".
|
||||
# You can put \n's in the value part of an alias to insert newlines.
|
||||
|
||||
ALIASES =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The QUIET tag can be used to turn on/off the messages that are generated
|
||||
# by doxygen. Possible values are YES and NO. If left blank NO is used.
|
||||
|
||||
QUIET = NO
|
||||
|
||||
# The WARNINGS tag can be used to turn on/off the warning messages that are
|
||||
# generated by doxygen. Possible values are YES and NO. If left blank
|
||||
# NO is used.
|
||||
|
||||
WARNINGS = YES
|
||||
|
||||
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
|
||||
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
|
||||
# automatically be disabled.
|
||||
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
|
||||
# The WARN_FORMAT tag determines the format of the warning messages that
|
||||
# doxygen can produce. The string should contain the $file, $line, and $text
|
||||
# tags, which will be replaced by the file and line number from which the
|
||||
# warning originated and the warning text.
|
||||
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
|
||||
# The WARN_LOGFILE tag can be used to specify a file to which warning
|
||||
# and error messages should be written. If left blank the output is written
|
||||
# to stderr.
|
||||
|
||||
WARN_LOGFILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The INPUT tag can be used to specify the files and/or directories that contain
|
||||
# documented source files. You may enter file names like "myfile.cpp" or
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = src/LinearMath src/BulletCollision src/BulletDynamics src/BulletSoftBody src/btBulletCollisionCommon.h src/btBulletDynamicsCommon.h Extras/Serialize/BulletWorldImporter Extras/Serialize/BulletFileLoader
|
||||
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
# and *.h) to filter out the source-files in the directories. If left
|
||||
# blank all files are included.
|
||||
|
||||
FILE_PATTERNS = *.h *.cpp *.c
|
||||
|
||||
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
|
||||
# should be searched for input files as well. Possible values are YES and NO.
|
||||
# If left blank NO is used.
|
||||
|
||||
RECURSIVE = YES
|
||||
|
||||
# The EXCLUDE tag can be used to specify files and/or directories that should
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||
|
||||
EXCLUDE =
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
|
||||
# certain files from those directories.
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
|
||||
# The EXAMPLE_PATH tag can be used to specify one or more files or
|
||||
# directories that contain example code fragments that are included (see
|
||||
# the \include command).
|
||||
|
||||
EXAMPLE_PATH =
|
||||
|
||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
||||
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
# and *.h) to filter out the source-files in the directories. If left
|
||||
# blank all files are included.
|
||||
|
||||
EXAMPLE_PATTERNS =
|
||||
|
||||
# The IMAGE_PATH tag can be used to specify one or more files or
|
||||
# directories that contain image that are included in the documentation (see
|
||||
# the \image command).
|
||||
|
||||
IMAGE_PATH =
|
||||
|
||||
# The INPUT_FILTER tag can be used to specify a program that doxygen should
|
||||
# invoke to filter for each input file. Doxygen will invoke the filter program
|
||||
# by executing (via popen()) the command <filter> <input-file>, where <filter>
|
||||
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
|
||||
# input file. Doxygen will then use the output that the filter program writes
|
||||
# to standard output.
|
||||
|
||||
INPUT_FILTER =
|
||||
|
||||
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
|
||||
# INPUT_FILTER) will be used to filter the input files when producing source
|
||||
# files to browse.
|
||||
|
||||
FILTER_SOURCE_FILES = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
|
||||
# of all compounds will be generated. Enable this if the project
|
||||
# contains a lot of classes, structs, unions or interfaces.
|
||||
|
||||
ALPHABETICAL_INDEX = NO
|
||||
|
||||
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
|
||||
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
|
||||
# in which this list will be split (can be a number in the range [1..20])
|
||||
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
|
||||
# In case all classes in a project start with a common prefix, all
|
||||
# classes will be put under the same header in the alphabetical index.
|
||||
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
|
||||
# should be ignored while generating the index headers.
|
||||
|
||||
IGNORE_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
|
||||
# generate HTML output.
|
||||
|
||||
GENERATE_HTML = YES
|
||||
|
||||
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `html' will be used as the default path.
|
||||
|
||||
HTML_OUTPUT = html
|
||||
|
||||
# The HTML_HEADER tag can be used to specify a personal HTML header for
|
||||
# each generated HTML page. If it is left blank doxygen will generate a
|
||||
# standard header.
|
||||
|
||||
HTML_HEADER =
|
||||
|
||||
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
|
||||
# each generated HTML page. If it is left blank doxygen will generate a
|
||||
# standard footer.
|
||||
|
||||
HTML_FOOTER =
|
||||
|
||||
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
|
||||
# style sheet that is used by each HTML page. It can be used to
|
||||
# fine-tune the look of the HTML output. If the tag is left blank doxygen
|
||||
# will generate a default style sheet
|
||||
|
||||
HTML_STYLESHEET =
|
||||
|
||||
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
|
||||
# files or namespaces will be aligned in HTML using tables. If set to
|
||||
# NO a bullet list will be used.
|
||||
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
|
||||
# will be generated that can be used as input for tools like the
|
||||
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
|
||||
# of the generated HTML documentation.
|
||||
|
||||
GENERATE_HTMLHELP = YES
|
||||
|
||||
# HHC_LOCATION = "C:\Program Files\HTML Help Workshop\hhc.exe"
|
||||
HHC_LOCATION = "C:\Program Files (x86)\HTML Help Workshop\hhc.exe"
|
||||
|
||||
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
#HTML_STYLESHEET = "\\server\exchange\Software Development\Documentation\DoxyGen\doxygen.css"
|
||||
|
||||
CHM_FILE = BulletDocs.chm
|
||||
HHC_LOCATION = "c:\program files\HTML Help Workshop\hhc.exe"
|
||||
GENERATE_CHI = YES
|
||||
BINARY_TOC = YES
|
||||
|
||||
TOC_EXPAND = YES
|
||||
|
||||
SHOW_DIRECTORIES = YES
|
||||
|
||||
|
||||
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
|
||||
# top of each HTML page. The value NO (the default) enables the index and
|
||||
# the value YES disables it.
|
||||
|
||||
DISABLE_INDEX = NO
|
||||
|
||||
# This tag can be used to set the number of enum values (range [1..20])
|
||||
# that doxygen will group on one line in the generated HTML documentation.
|
||||
|
||||
ENUM_VALUES_PER_LINE = 1
|
||||
|
||||
# If the GENERATE_TREEVIEW tag is set to YES, a side pannel will be
|
||||
# generated containing a tree-like index structure (just like the one that
|
||||
# is generated for HTML Help). For this to work a browser that supports
|
||||
# JavaScript and frames is required (for instance Netscape 4.0+
|
||||
# or Internet explorer 4.0+).
|
||||
|
||||
GENERATE_TREEVIEW = YES
|
||||
|
||||
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
|
||||
# used to set the initial width (in pixels) of the frame in which the tree
|
||||
# is shown.
|
||||
|
||||
TREEVIEW_WIDTH = 250
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
|
||||
# generate Latex output.
|
||||
|
||||
GENERATE_LATEX = NO
|
||||
|
||||
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `latex' will be used as the default path.
|
||||
|
||||
LATEX_OUTPUT = latex
|
||||
|
||||
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
|
||||
# LaTeX documents. This may be useful for small projects and may help to
|
||||
# save some trees in general.
|
||||
|
||||
COMPACT_LATEX = NO
|
||||
|
||||
# The PAPER_TYPE tag can be used to set the paper type that is used
|
||||
# by the printer. Possible values are: a4, a4wide, letter, legal and
|
||||
# executive. If left blank a4wide will be used.
|
||||
|
||||
PAPER_TYPE = a4wide
|
||||
|
||||
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
|
||||
# packages that should be included in the LaTeX output.
|
||||
|
||||
EXTRA_PACKAGES =
|
||||
|
||||
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
|
||||
# the generated latex document. The header should contain everything until
|
||||
# the first chapter. If it is left blank doxygen will generate a
|
||||
# standard header. Notice: only use this tag if you know what you are doing!
|
||||
|
||||
LATEX_HEADER =
|
||||
|
||||
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
|
||||
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
|
||||
# contain links (just like the HTML output) instead of page references
|
||||
# This makes the output suitable for online browsing using a pdf viewer.
|
||||
|
||||
PDF_HYPERLINKS = NO
|
||||
|
||||
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
|
||||
# plain latex in the generated Makefile. Set this option to YES to get a
|
||||
# higher quality PDF documentation.
|
||||
|
||||
USE_PDFLATEX = NO
|
||||
|
||||
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
|
||||
# command to the generated LaTeX files. This will instruct LaTeX to keep
|
||||
# running if errors occur, instead of asking the user for help.
|
||||
# This option is also used when generating formulas in HTML.
|
||||
|
||||
LATEX_BATCHMODE = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
|
||||
# The RTF output is optimised for Word 97 and may not look very pretty with
|
||||
# other RTF readers or editors.
|
||||
|
||||
GENERATE_RTF = NO
|
||||
|
||||
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `rtf' will be used as the default path.
|
||||
|
||||
RTF_OUTPUT = rtf
|
||||
|
||||
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
|
||||
# RTF documents. This may be useful for small projects and may help to
|
||||
# save some trees in general.
|
||||
|
||||
COMPACT_RTF = NO
|
||||
|
||||
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
|
||||
# will contain hyperlink fields. The RTF file will
|
||||
# contain links (just like the HTML output) instead of page references.
|
||||
# This makes the output suitable for online browsing using a WORD or other.
|
||||
# programs which support those fields.
|
||||
# Note: wordpad (write) and others do not support links.
|
||||
|
||||
RTF_HYPERLINKS = NO
|
||||
|
||||
# Load stylesheet definitions from file. Syntax is similar to doxygen's
|
||||
# config file, i.e. a series of assigments. You only have to provide
|
||||
# replacements, missing definitions are set to their default value.
|
||||
|
||||
RTF_STYLESHEET_FILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
|
||||
# generate man pages
|
||||
|
||||
GENERATE_MAN = NO
|
||||
|
||||
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
|
||||
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
|
||||
# put in front of it. If left blank `man' will be used as the default path.
|
||||
|
||||
MAN_OUTPUT = man
|
||||
|
||||
# The MAN_EXTENSION tag determines the extension that is added to
|
||||
# the generated man pages (default is the subroutine's section .3)
|
||||
|
||||
MAN_EXTENSION = .3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_XML tag is set to YES Doxygen will
|
||||
# generate an XML file that captures the structure of
|
||||
# the code including all documentation. Warning: This feature
|
||||
# is still experimental and very incomplete.
|
||||
|
||||
GENERATE_XML = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
|
||||
# evaluate all C-preprocessor directives found in the sources and include
|
||||
# files.
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
|
||||
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
|
||||
# names in the source code. If set to NO (the default) only conditional
|
||||
# compilation will be performed. Macro expansion can be done in a controlled
|
||||
# way by setting EXPAND_ONLY_PREDEF to YES.
|
||||
|
||||
MACRO_EXPANSION = YES
|
||||
|
||||
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
|
||||
# then the macro expansion is limited to the macros specified with the
|
||||
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
|
||||
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
|
||||
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
|
||||
# in the INCLUDE_PATH (see below) will be search if a #include is found.
|
||||
|
||||
SEARCH_INCLUDES = YES
|
||||
|
||||
# The INCLUDE_PATH tag can be used to specify one or more directories that
|
||||
# contain include files that are not input files but should be processed by
|
||||
# the preprocessor.
|
||||
|
||||
INCLUDE_PATH =
|
||||
|
||||
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
|
||||
# patterns (like *.h and *.hpp) to filter out the header-files in the
|
||||
# directories. If left blank, the patterns specified with FILE_PATTERNS will
|
||||
# be used.
|
||||
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
|
||||
# The PREDEFINED tag can be used to specify one or more macro names that
|
||||
# are defined before the preprocessor is started (similar to the -D option of
|
||||
# gcc). The argument of the tag is a list of macros of the form: name
|
||||
# or name=definition (no spaces). If the definition and the = are
|
||||
# omitted =1 is assumed.
|
||||
|
||||
PREDEFINED = "ATTRIBUTE_ALIGNED128(x)=x" \
|
||||
"ATTRIBUTE_ALIGNED16(x)=x" \
|
||||
"SIMD_FORCE_INLINE=inline" \
|
||||
"VECTORMATH_FORCE_INLINE=inline" \
|
||||
"USE_WIN32_THREADING=1"\
|
||||
"USE_PTHREADS=1"\
|
||||
"_WIN32=1"
|
||||
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
|
||||
# this tag can be used to specify a list of macro names that should be expanded.
|
||||
# The macro definition that is found in the sources will be used.
|
||||
# Use the PREDEFINED tag if you want to use a different macro definition.
|
||||
|
||||
EXPAND_AS_DEFINED =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The TAGFILES tag can be used to specify one or more tagfiles.
|
||||
|
||||
TAGFILES =
|
||||
|
||||
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
|
||||
# a tag file that is based on the input files it reads.
|
||||
|
||||
GENERATE_TAGFILE =
|
||||
|
||||
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
|
||||
# in the class index. If set to NO only the inherited external classes
|
||||
# will be listed.
|
||||
|
||||
ALLEXTERNALS = NO
|
||||
|
||||
# The PERL_PATH should be the absolute path and name of the perl script
|
||||
# interpreter (i.e. the result of `which perl').
|
||||
|
||||
PERL_PATH = /usr/bin/perl
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
|
||||
# available from the path. This tool is part of Graphviz, a graph visualization
|
||||
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
||||
# have no effect if this option is set to NO (the default)
|
||||
|
||||
HAVE_DOT = YES
|
||||
|
||||
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect inheritance relations. Setting this tag to YES will force the
|
||||
# the CLASS_DIAGRAMS tag to NO.
|
||||
|
||||
CLASS_GRAPH = YES
|
||||
|
||||
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect implementation dependencies (inheritance, containment, and
|
||||
# class references variables) of the class with other documented classes.
|
||||
|
||||
COLLABORATION_GRAPH = YES
|
||||
|
||||
# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to
|
||||
# YES then doxygen will generate a graph for each documented file showing
|
||||
# the direct and indirect include dependencies of the file with other
|
||||
# documented files.
|
||||
|
||||
INCLUDE_GRAPH = YES
|
||||
|
||||
# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to
|
||||
# YES then doxygen will generate a graph for each documented header file showing
|
||||
# the documented files that directly or indirectly include this file
|
||||
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
|
||||
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
|
||||
# will graphical hierarchy of all classes instead of a textual one.
|
||||
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
|
||||
# The tag DOT_PATH can be used to specify the path where the dot tool can be
|
||||
# found. If left blank, it is assumed the dot tool can be found on the path.
|
||||
|
||||
DOT_PATH =
|
||||
|
||||
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
|
||||
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
|
||||
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
|
||||
# this value, doxygen will try to truncate the graph, so that it fits within
|
||||
# the specified constraint. Beware that most browsers cannot cope with very
|
||||
# large images.
|
||||
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
|
||||
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
|
||||
# generate a legend page explaining the meaning of the various boxes and
|
||||
# arrows in the dot generated graphs.
|
||||
|
||||
GENERATE_LEGEND = YES
|
||||
|
||||
|
||||
# delete intermediate dot files?
|
||||
|
||||
DOT_CLEANUP = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::addtions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# The SEARCHENGINE tag specifies whether or not a search engine should be
|
||||
# used. If set to NO the values of all tags below this one will be ignored.
|
||||
|
||||
SEARCHENGINE = NO
|
||||
|
||||
# The CGI_NAME tag should be the name of the CGI script that
|
||||
# starts the search engine (doxysearch) with the correct parameters.
|
||||
# A script with this name will be generated by doxygen.
|
||||
|
||||
CGI_NAME = search.cgi
|
||||
|
||||
# The CGI_URL tag should be the absolute URL to the directory where the
|
||||
# cgi binaries are located. See the documentation of your http daemon for
|
||||
# details.
|
||||
|
||||
CGI_URL =
|
||||
|
||||
# The DOC_URL tag should be the absolute URL to the directory where the
|
||||
# documentation is located. If left blank the absolute path to the
|
||||
# documentation, with file:// prepended to it, will be used.
|
||||
|
||||
DOC_URL =
|
||||
|
||||
# The DOC_ABSPATH tag should be the absolute path to the directory where the
|
||||
# documentation is located. If left blank the directory on the local machine
|
||||
# will be used.
|
||||
|
||||
DOC_ABSPATH =
|
||||
|
||||
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
|
||||
# is installed.
|
||||
|
||||
BIN_ABSPATH = c:\program files\doxygen\bin
|
||||
|
||||
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
|
||||
# documentation generated for other projects. This allows doxysearch to search
|
||||
# the documentation for these projects as well.
|
||||
|
||||
EXT_DOC_PATHS =
|
||||
@@ -953,6 +953,64 @@ void btWorldImporter::convertConstraintFloat(btTypedConstraintFloatData* constra
|
||||
constraint = gear;
|
||||
break;
|
||||
}
|
||||
case D6_SPRING_2_CONSTRAINT_TYPE:
|
||||
{
|
||||
|
||||
btGeneric6DofSpring2ConstraintData* dofData = (btGeneric6DofSpring2ConstraintData*)constraintData;
|
||||
|
||||
btGeneric6DofSpring2Constraint* dof = 0;
|
||||
|
||||
if (rbA && rbB)
|
||||
{
|
||||
btTransform rbAFrame,rbBFrame;
|
||||
rbAFrame.deSerializeFloat(dofData->m_rbAFrame);
|
||||
rbBFrame.deSerializeFloat(dofData->m_rbBFrame);
|
||||
dof = createGeneric6DofSpring2Constraint(*rbA,*rbB,rbAFrame,rbBFrame, dofData->m_rotateOrder);
|
||||
} else
|
||||
{
|
||||
printf("Error in btWorldImporter::createGeneric6DofSpring2Constraint: requires rbA && rbB\n");
|
||||
}
|
||||
|
||||
if (dof)
|
||||
{
|
||||
btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit;
|
||||
angLowerLimit.deSerializeFloat(dofData->m_angularLowerLimit);
|
||||
angUpperLimit.deSerializeFloat(dofData->m_angularUpperLimit);
|
||||
linLowerLimit.deSerializeFloat(dofData->m_linearLowerLimit);
|
||||
linUpperlimit.deSerializeFloat(dofData->m_linearUpperLimit);
|
||||
|
||||
angLowerLimit.setW(0.f);
|
||||
dof->setAngularLowerLimit(angLowerLimit);
|
||||
dof->setAngularUpperLimit(angUpperLimit);
|
||||
dof->setLinearLowerLimit(linLowerLimit);
|
||||
dof->setLinearUpperLimit(linUpperlimit);
|
||||
|
||||
int i;
|
||||
if (fileVersion>280)
|
||||
{
|
||||
//6-dof: 3 linear followed by 3 angular
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
dof->setStiffness(i,dofData->m_linearSpringStiffness.m_floats[i]);
|
||||
dof->setEquilibriumPoint(i,dofData->m_linearEquilibriumPoint.m_floats[i]);
|
||||
dof->enableSpring(i,dofData->m_linearEnableSpring[i]!=0);
|
||||
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i]);
|
||||
}
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i]);
|
||||
dof->setEquilibriumPoint(i+3,dofData->m_angularEquilibriumPoint.m_floats[i]);
|
||||
dof->enableSpring(i+3,dofData->m_angularEnableSpring[i]!=0);
|
||||
dof->setDamping(i+3,dofData->m_angularSpringDamping.m_floats[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
constraint = dof;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("unknown constraint type\n");
|
||||
@@ -1193,6 +1251,65 @@ void btWorldImporter::convertConstraintDouble(btTypedConstraintDoubleData* const
|
||||
constraint = gear;
|
||||
break;
|
||||
}
|
||||
|
||||
case D6_SPRING_2_CONSTRAINT_TYPE:
|
||||
{
|
||||
|
||||
btGeneric6DofSpring2ConstraintDoubleData2* dofData = (btGeneric6DofSpring2ConstraintDoubleData2*)constraintData;
|
||||
|
||||
btGeneric6DofSpring2Constraint* dof = 0;
|
||||
|
||||
if (rbA && rbB)
|
||||
{
|
||||
btTransform rbAFrame,rbBFrame;
|
||||
rbAFrame.deSerializeDouble(dofData->m_rbAFrame);
|
||||
rbBFrame.deSerializeDouble(dofData->m_rbBFrame);
|
||||
dof = createGeneric6DofSpring2Constraint(*rbA,*rbB,rbAFrame,rbBFrame, dofData->m_rotateOrder);
|
||||
} else
|
||||
{
|
||||
printf("Error in btWorldImporter::createGeneric6DofSpring2Constraint: requires rbA && rbB\n");
|
||||
}
|
||||
|
||||
if (dof)
|
||||
{
|
||||
btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit;
|
||||
angLowerLimit.deSerializeDouble(dofData->m_angularLowerLimit);
|
||||
angUpperLimit.deSerializeDouble(dofData->m_angularUpperLimit);
|
||||
linLowerLimit.deSerializeDouble(dofData->m_linearLowerLimit);
|
||||
linUpperlimit.deSerializeDouble(dofData->m_linearUpperLimit);
|
||||
|
||||
angLowerLimit.setW(0.f);
|
||||
dof->setAngularLowerLimit(angLowerLimit);
|
||||
dof->setAngularUpperLimit(angUpperLimit);
|
||||
dof->setLinearLowerLimit(linLowerLimit);
|
||||
dof->setLinearUpperLimit(linUpperlimit);
|
||||
|
||||
int i;
|
||||
if (fileVersion>280)
|
||||
{
|
||||
//6-dof: 3 linear followed by 3 angular
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
dof->setStiffness(i,dofData->m_linearSpringStiffness.m_floats[i]);
|
||||
dof->setEquilibriumPoint(i,dofData->m_linearEquilibriumPoint.m_floats[i]);
|
||||
dof->enableSpring(i,dofData->m_linearEnableSpring[i]!=0);
|
||||
dof->setDamping(i,dofData->m_linearSpringDamping.m_floats[i]);
|
||||
}
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
dof->setStiffness(i+3,dofData->m_angularSpringStiffness.m_floats[i]);
|
||||
dof->setEquilibriumPoint(i+3,dofData->m_angularEquilibriumPoint.m_floats[i]);
|
||||
dof->enableSpring(i+3,dofData->m_angularEnableSpring[i]!=0);
|
||||
dof->setDamping(i+3,dofData->m_angularSpringDamping.m_floats[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
constraint = dof;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("unknown constraint type\n");
|
||||
@@ -1711,6 +1828,15 @@ btGeneric6DofConstraint* btWorldImporter::createGeneric6DofConstraint(btRigidBod
|
||||
return dof;
|
||||
}
|
||||
|
||||
btGeneric6DofSpring2Constraint* btWorldImporter::createGeneric6DofSpring2Constraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, int rotateOrder)
|
||||
{
|
||||
btGeneric6DofSpring2Constraint* dof = new btGeneric6DofSpring2Constraint(rbA,rbB,frameInA,frameInB, (RotateOrder)rotateOrder);
|
||||
m_allocatedConstraints.push_back(dof);
|
||||
return dof;
|
||||
}
|
||||
|
||||
|
||||
|
||||
btGeneric6DofSpringConstraint* btWorldImporter::createGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA)
|
||||
{
|
||||
btGeneric6DofSpringConstraint* dof = new btGeneric6DofSpringConstraint(rbA,rbB,frameInA,frameInB,useLinearReferenceFrameA);
|
||||
|
||||
@@ -42,6 +42,7 @@ class btHingeConstraint;
|
||||
class btConeTwistConstraint;
|
||||
class btGeneric6DofConstraint;
|
||||
class btGeneric6DofSpringConstraint;
|
||||
class btGeneric6DofSpring2Constraint;
|
||||
class btSliderConstraint;
|
||||
class btGearConstraint;
|
||||
struct btContactSolverInfo;
|
||||
@@ -199,6 +200,8 @@ public:
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofConstraint* createGeneric6DofConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameB);
|
||||
virtual btGeneric6DofSpringConstraint* createGeneric6DofSpringConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btGeneric6DofSpring2Constraint* createGeneric6DofSpring2Constraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB, int rotateOrder );
|
||||
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA);
|
||||
virtual btSliderConstraint* createSliderConstraint(btRigidBody& rbB, const btTransform& frameInB, bool useLinearReferenceFrameA);
|
||||
virtual btGearConstraint* createGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA,const btVector3& axisInB, btScalar ratio);
|
||||
|
||||
BIN
docs/GPU_rigidbody_using_OpenCL.pdf
Normal file
BIN
docs/GPU_rigidbody_using_OpenCL.pdf
Normal file
Binary file not shown.
@@ -25,10 +25,13 @@ Bullet Physics is a professional open source collision detection, rigid body and
|
||||
|
||||
\subsection{New in Bullet 2.83}
|
||||
\begin{itemize}
|
||||
\item New ExampleBrowser, replacing the standalone demos. See \path{examples/ExampleBrowser}.
|
||||
\item Import of Universal Robot Description Files (URDF). See \path{examples/Importers/ImportURDFDemo}.
|
||||
\item New ExampleBrowser, replacing the standalone demos. Not all demos have been ported over yet, it will happen in upcoming releases. It is recommended to use an OpenGL 3+ system, although there is limited OpenGL 2 fallback. See \path{examples/ExampleBrowser}.
|
||||
\item Import of Universal Robot Description Files (URDF). See \path{examples/Importers/ImportURDFDemo}. You can use File-Open in the ExampleBrowser.
|
||||
\item Improved support for btMultiBody with multi-degree of freedom mobilizers, thanks to Jakub Stepien. See \path{examples/MultiBody/MultiDofDemo}.
|
||||
\item New btGeneric6DofSpring2Constraint, replacing the old generic 6dof constraint, thanks to Gabor PUHR and Tamas Umenhoffer. See \path{examples/Dof6Spring2Setup}
|
||||
\item OpenCL demo integrated in the ExampleBrowser. The demo is disabled by default, because it only works on high-end desktop GPU systems with compatible up-to-date OpenCL 1.1+ driver. Use $--enable\_experimental\_opencl$ command-line argument in the ExampleBrowser.
|
||||
|
||||
|
||||
\end{itemize}
|
||||
\subsection{New in Bullet 2.82}
|
||||
\begin{itemize}
|
||||
|
||||
@@ -37,6 +37,14 @@ struct BasicExample : public CommonRigidBodyBase
|
||||
virtual ~BasicExample(){}
|
||||
virtual void initPhysics();
|
||||
virtual void renderScene();
|
||||
void resetCamera()
|
||||
{
|
||||
float dist = 41;
|
||||
float pitch = 52;
|
||||
float yaw = 35;
|
||||
float targetPos[3]={0,0.46,0};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
};
|
||||
|
||||
void BasicExample::initPhysics()
|
||||
@@ -52,7 +60,7 @@ void BasicExample::initPhysics()
|
||||
|
||||
///create a few basic rigid bodies
|
||||
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||
m_guiHelper->createCollisionShapeGraphicsObject(groundShape);
|
||||
|
||||
|
||||
//groundShape->initializePolyhedralFeatures();
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
@@ -66,7 +74,6 @@ void BasicExample::initPhysics()
|
||||
{
|
||||
btScalar mass(0.);
|
||||
btRigidBody* body = createRigidBody(mass,groundTransform,groundShape, btVector4(0,0,1,1));
|
||||
m_guiHelper->createRigidBodyGraphicsObject(body, btVector3(0, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +82,7 @@ void BasicExample::initPhysics()
|
||||
// Re-using the same collision is better for memory usage and performance
|
||||
|
||||
btBoxShape* colShape = createBoxShape(btVector3(1,1,1));
|
||||
m_guiHelper->createCollisionShapeGraphicsObject(colShape);
|
||||
|
||||
|
||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||
m_collisionShapes.push_back(colShape);
|
||||
@@ -107,14 +114,14 @@ void BasicExample::initPhysics()
|
||||
|
||||
|
||||
btRigidBody* body = createRigidBody(mass,startTransform,colShape);
|
||||
m_guiHelper->createRigidBodyGraphicsObject(body, btVector3(1, 1, 0));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,9 +135,11 @@ void BasicExample::renderScene()
|
||||
|
||||
|
||||
|
||||
CommonExampleInterface* BasicExampleCreateFunc(PhysicsInterface* pint, GUIHelperInterface* helper, int option)
|
||||
|
||||
|
||||
CommonExampleInterface* BasicExampleCreateFunc(CommonExampleOptions& options)
|
||||
{
|
||||
return new BasicExample(helper);
|
||||
return new BasicExample(options.m_guiHelper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
||||
#ifndef BASIC_EXAMPLE_H
|
||||
#define BASIC_EXAMPLE_H
|
||||
|
||||
class CommonExampleInterface* BasicExampleCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* BasicExampleCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //BASIC_DEMO_PHYSICS_SETUP_H
|
||||
|
||||
@@ -28,9 +28,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
DummyGUIHelper noGfx;
|
||||
|
||||
int option = 0;
|
||||
|
||||
CommonExampleInterface* example = BasicExampleCreateFunc(pint, &noGfx, option);
|
||||
CommonExampleOptions options(&noGfx);
|
||||
CommonExampleInterface* example = BasicExampleCreateFunc(options);
|
||||
|
||||
example->initPhysics();
|
||||
example->stepSimulation(1.f/60.f);
|
||||
|
||||
@@ -1234,7 +1234,7 @@ void BenchmarkDemo::exitPhysics()
|
||||
|
||||
|
||||
|
||||
struct CommonExampleInterface* BenchmarkCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
struct CommonExampleInterface* BenchmarkCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new BenchmarkDemo(helper,option);
|
||||
return new BenchmarkDemo(options.m_guiHelper,options.m_option);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef BENCHMARK_EXAMPLE_H
|
||||
#define BENCHMARK_EXAMPLE_H
|
||||
|
||||
class CommonExampleInterface* BenchmarkCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* BenchmarkCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,23 +3,43 @@
|
||||
#ifndef COMMON_EXAMPLE_INTERFACE_H
|
||||
#define COMMON_EXAMPLE_INTERFACE_H
|
||||
|
||||
struct CommonExampleOptions
|
||||
{
|
||||
struct GUIHelperInterface* m_guiHelper;
|
||||
|
||||
//Those are optional, some examples will use them others don't. Each example should work with them being 0.
|
||||
int m_option;
|
||||
const char* m_fileName;
|
||||
|
||||
|
||||
CommonExampleOptions(struct GUIHelperInterface* helper, int option=0)
|
||||
:m_guiHelper(helper),
|
||||
m_option(option),
|
||||
m_fileName(0)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class CommonExampleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
typedef class CommonExampleInterface* (CreateFunc)(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
typedef class CommonExampleInterface* (CreateFunc)(CommonExampleOptions& options);
|
||||
|
||||
virtual ~CommonExampleInterface()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void initPhysics()=0;
|
||||
virtual void exitPhysics()=0;
|
||||
virtual void stepSimulation(float deltaTime)=0;
|
||||
virtual void renderScene()=0;
|
||||
virtual void physicsDebugDraw(int debugFlags)=0;//for now we reuse the flags in Bullet/src/LinearMath/btIDebugDraw.h
|
||||
//reset camera is only called when switching demo. this way you can restart (initPhysics) and watch in a specific location easier
|
||||
virtual void resetCamera(){};
|
||||
virtual bool mouseMoveCallback(float x,float y)=0;
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y)=0;
|
||||
virtual bool keyboardCallback(int key, int state)=0;
|
||||
|
||||
@@ -43,6 +43,8 @@ struct GUIHelperInterface
|
||||
|
||||
virtual void setUpAxis(int axis)=0;
|
||||
|
||||
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)=0;
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;
|
||||
|
||||
virtual void drawText3D( const char* txt, float posX, float posZY, float posZ, float size)=0;
|
||||
@@ -97,6 +99,9 @@ struct DummyGUIHelper : public GUIHelperInterface
|
||||
virtual void setUpAxis(int axis)
|
||||
{
|
||||
}
|
||||
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld)
|
||||
{
|
||||
|
||||
@@ -140,10 +140,8 @@ struct CommonMultiBodyBase : public CommonExampleInterface
|
||||
{
|
||||
m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld);
|
||||
|
||||
if (m_guiHelper->getRenderInterface())
|
||||
{
|
||||
m_guiHelper->getRenderInterface()->renderScene();
|
||||
}
|
||||
m_guiHelper->render(m_dynamicsWorld);
|
||||
|
||||
}
|
||||
|
||||
virtual void physicsDebugDraw(int debugDrawFlags)
|
||||
|
||||
@@ -51,6 +51,10 @@ struct CommonRenderInterface
|
||||
|
||||
virtual void writeTransforms()=0;
|
||||
virtual void enableBlend(bool blend)=0;
|
||||
|
||||
//This is internal access to OpenGL3+ features, mainly used for OpenCL-OpenGL interop
|
||||
//Only the GLInstancingRenderer supports it, just return 0 otherwise.
|
||||
virtual struct GLInstanceRendererInternalData* getInternalData()=0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -25,6 +25,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
//data for picking objects
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btTypedConstraint* m_pickedConstraint;
|
||||
int m_savedState;
|
||||
btVector3 m_oldPickingPos;
|
||||
btVector3 m_hitPos;
|
||||
btScalar m_oldPickingDist;
|
||||
@@ -156,6 +157,19 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
|
||||
virtual bool keyboardCallback(int key, int state)
|
||||
{
|
||||
if ((key==B3G_F3) && state && m_dynamicsWorld)
|
||||
{
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen("testFile.bullet","wb");
|
||||
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
|
||||
fclose(file);
|
||||
//b3Printf("btDefaultSerializer wrote testFile.bullet");
|
||||
delete serializer;
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;//don't handle this key
|
||||
}
|
||||
|
||||
@@ -329,6 +343,7 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
if (!(body->isStaticObject() || body->isKinematicObject()))
|
||||
{
|
||||
m_pickedBody = body;
|
||||
m_savedState = m_pickedBody->getActivationState();
|
||||
m_pickedBody->setActivationState(DISABLE_DEACTIVATION);
|
||||
//printf("pickPos=%f,%f,%f\n",pickPos.getX(),pickPos.getY(),pickPos.getZ());
|
||||
btVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos;
|
||||
@@ -378,6 +393,8 @@ struct CommonRigidBodyBase : public CommonExampleInterface
|
||||
{
|
||||
if (m_pickedConstraint)
|
||||
{
|
||||
m_pickedBody->forceActivationState(m_savedState);
|
||||
m_pickedBody->activate();
|
||||
m_dynamicsWorld->removeConstraint(m_pickedConstraint);
|
||||
delete m_pickedConstraint;
|
||||
m_pickedConstraint = 0;
|
||||
|
||||
@@ -43,12 +43,19 @@ class AllConstraintDemo : public CommonRigidBodyBase
|
||||
|
||||
virtual ~AllConstraintDemo();
|
||||
|
||||
void initPhysics();
|
||||
virtual void initPhysics();
|
||||
|
||||
void exitPhysics();
|
||||
virtual void exitPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 27;
|
||||
float pitch = 720;
|
||||
float yaw = 30;
|
||||
float targetPos[3]={2,0,-10};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
||||
|
||||
// for cone-twist motor driving
|
||||
@@ -872,7 +879,7 @@ void AllConstraintDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* AllConstraintCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* AllConstraintCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new AllConstraintDemo(helper);
|
||||
return new AllConstraintDemo(options.m_guiHelper);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef ALL_CONSTRAINT_DEMO_H
|
||||
#define ALL_CONSTRAINT_DEMO_H
|
||||
|
||||
class CommonExampleInterface* AllConstraintCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* AllConstraintCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //ALL_CONSTRAINT_DEMO_H
|
||||
|
||||
@@ -14,6 +14,17 @@ struct ConstraintPhysicsSetup : public CommonRigidBodyBase
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 7;
|
||||
float pitch = 721;
|
||||
float yaw = 44;
|
||||
float targetPos[3]={8,1,-11};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
ConstraintPhysicsSetup::ConstraintPhysicsSetup(struct GUIHelperInterface* helper)
|
||||
@@ -144,7 +155,7 @@ void ConstraintPhysicsSetup::initPhysics()
|
||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ConstraintCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ConstraintCreateFunc(CommonExampleOptions& options)
|
||||
{
|
||||
return new ConstraintPhysicsSetup(helper);
|
||||
return new ConstraintPhysicsSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef CONSTAINT_PHYSICS_SETUP_H
|
||||
#define CONSTAINT_PHYSICS_SETUP_H
|
||||
|
||||
class CommonExampleInterface* ConstraintCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ConstraintCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //CONSTAINT_PHYSICS_SETUP_H
|
||||
|
||||
@@ -51,6 +51,15 @@ struct Dof6Spring2Setup : public CommonRigidBodyBase
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
void animate();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 5;
|
||||
float pitch = 722;
|
||||
float yaw = 35;
|
||||
float targetPos[3]={4,2,-11};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -475,7 +484,7 @@ void Dof6Spring2Setup::stepSimulation(float deltaTime)
|
||||
m_dynamicsWorld->stepSimulation(deltaTime);
|
||||
}
|
||||
|
||||
class CommonExampleInterface* Dof6Spring2CreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* Dof6Spring2CreateFunc( CommonExampleOptions& options)
|
||||
{
|
||||
return new Dof6Spring2Setup(helper);
|
||||
return new Dof6Spring2Setup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef GENERIC_6DOF_SPRING2_CONSTRAINT_DEMO_H
|
||||
#define GENERIC_6DOF_SPRING2_CONSTRAINT_DEMO_H
|
||||
|
||||
class CommonExampleInterface* Dof6Spring2CreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* Dof6Spring2CreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //GENERIC_6DOF_SPRING2_CONSTRAINT_DEMO_H
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
EmptyExample() {}
|
||||
virtual ~EmptyExample(){}
|
||||
|
||||
static CommonExampleInterface* CreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
static CommonExampleInterface* CreateFunc(struct CommonExampleOptions& /* unusedOptions*/)
|
||||
{
|
||||
return new EmptyExample;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,14 @@
|
||||
#include "../Experiments/ImplicitCloth/ImplicitClothExample.h"
|
||||
#include "../Importers/ImportBullet/SerializeSetup.h"
|
||||
#include "../Raycast/RaytestDemo.h"
|
||||
|
||||
|
||||
#ifdef B3_USE_CLEW
|
||||
#include "../OpenCL/broadphase/PairBench.h"
|
||||
#include "../OpenCL/rigidbody/GpuConvexScene.h"
|
||||
|
||||
#endif //B3_USE_CLEW
|
||||
|
||||
|
||||
|
||||
struct ExampleEntry
|
||||
@@ -56,19 +63,23 @@ static ExampleEntry gDefaultExamples[]=
|
||||
|
||||
|
||||
ExampleEntry(0,"API"),
|
||||
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application.", BasicExampleCreateFunc),
|
||||
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application. Press W for wireframe, A to show AABBs, I to suspend/restart physics simulation. ", BasicExampleCreateFunc),
|
||||
|
||||
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet. Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.",
|
||||
AllConstraintCreateFunc),
|
||||
|
||||
ExampleEntry(1,"Motorized Hinge","Use of a btHingeConstraint. You can adjust the first slider to change the target velocity, and the second slider to adjust the maximum impulse applied to reach the target velocity. Note that the hinge angle can reach beyond -360 and 360 degrees.", ConstraintCreateFunc),
|
||||
|
||||
// ExampleEntry(0,"What's new in 2.83"),
|
||||
|
||||
ExampleEntry(1,"6DofSpring2","Show the use of the btGeneric6DofSpring2Constraint. This is a replacement of the btGeneric6DofSpringConstraint, it has various improvements. This includes improved spring implementation and better control over the restitution (bounce) when the constraint hits its limits.",
|
||||
Dof6Spring2CreateFunc),
|
||||
|
||||
ExampleEntry(1,"Gyroscopic", "Show the Dzhanibekov effect using various settings of the gyroscopic term. You can select the gyroscopic term computation using btRigidBody::setFlags, with arguments BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT (using explicit integration, which adds energy and can lead to explosions), BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD, BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY. If you don't set any of these flags, there is no gyroscopic term used.", GyroscopicCreateFunc),
|
||||
|
||||
ExampleEntry(1,"Planar 2D","Show the use of 2D collision shapes and rigid body simulation. The collision shape is wrapped into a btConvex2dShape. The rigid bodies are restricted in a plane using the 'setAngularFactor' and 'setLinearFactor' API call.",Planar2DCreateFunc),
|
||||
ExampleEntry(1,"Constraints","Use of a btHingeConstraint. You can adjust the first slider to change the target velocity, and the second slider to adjust the maximum impulse applied to reach the target velocity. Note that the hinge angle can reach beyond -360 and 360 degrees.", ConstraintCreateFunc),
|
||||
ExampleEntry(1,"6DofSpring2","Show the use of the btGeneric6DofSpring2Constraint.",
|
||||
Dof6Spring2CreateFunc),
|
||||
|
||||
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet.",
|
||||
AllConstraintCreateFunc),
|
||||
|
||||
|
||||
|
||||
ExampleEntry(0,"MultiBody"),
|
||||
ExampleEntry(1,"MultiDofCreateFunc","Create a basic btMultiBody with 3-DOF spherical joints (mobilizers). The demo uses a fixed base or a floating base at restart.", MultiDofCreateFunc),
|
||||
ExampleEntry(1,"TestJointTorque","Apply a torque to a btMultiBody with 1-DOF joints (mobilizers).", TestJointTorqueCreateFunc),
|
||||
@@ -161,20 +172,28 @@ static ExampleEntry gDefaultExamples[]=
|
||||
ExampleEntry(1,"Voronoi Fracture", "Automatically create a compound rigid body using voronoi tesselation. Individual parts are modeled as rigid bodies using a btConvexHullShape.",
|
||||
VoronoiFractureCreateFunc),
|
||||
|
||||
ExampleEntry(1,"Planar 2D","Show the use of 2D collision shapes and rigid body simulation. The collision shape is wrapped into a btConvex2dShape. The rigid bodies are restricted in a plane using the 'setAngularFactor' and 'setLinearFactor' API call.",Planar2DCreateFunc),
|
||||
|
||||
ExampleEntry(1,"Implicit Cloth", "Cloth simulation using implicit integration, by Stan Melax. The cloth is only attached at the corners. Note the stability using a large time step even with high stiffness.",
|
||||
ImplicitClothCreateFunc),
|
||||
|
||||
#ifdef B3_USE_CLEW
|
||||
ExampleEntry(0,"OpenCL (experimental)"),
|
||||
ExampleEntry(1,"Pair Bench", "Benchmark of overlapping pair search using OpenCL.", PairBenchOpenCLCreateFunc),
|
||||
#endif //
|
||||
|
||||
ExampleEntry(0,"Rendering"),
|
||||
ExampleEntry(1,"Instanced Rendering", "Simple example of fast instanced rendering, only active when using OpenGL3+.",RenderInstancingCreateFunc),
|
||||
ExampleEntry(1,"CoordinateSystemDemo","Show the axis and positive rotation direction around the axis.", CoordinateSystemCreateFunc),
|
||||
|
||||
};
|
||||
|
||||
#ifdef B3_USE_CLEW
|
||||
static ExampleEntry gOpenCLExamples[]=
|
||||
{
|
||||
ExampleEntry(0,"OpenCL (experimental)"),
|
||||
ExampleEntry(1,"Box-Box", "Full OpenCL implementation of the entire physics and collision detection pipeline, showing box-box rigid body",
|
||||
OpenCLBoxBoxCreateFunc),
|
||||
ExampleEntry(1,"Pair Bench", "Benchmark of overlapping pair search using OpenCL.", PairBenchOpenCLCreateFunc),
|
||||
|
||||
};
|
||||
#endif //
|
||||
static btAlignedObjectArray<ExampleEntry> gAdditionalRegisteredExamples;
|
||||
|
||||
|
||||
@@ -193,6 +212,17 @@ ExampleEntries::~ExampleEntries()
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
void ExampleEntries::initOpenCLExampleEntries()
|
||||
{
|
||||
#ifdef B3_USE_CLEW
|
||||
int numDefaultEntries = sizeof(gOpenCLExamples)/sizeof(ExampleEntry);
|
||||
for (int i=0;i<numDefaultEntries;i++)
|
||||
{
|
||||
m_data->m_allExamples.push_back(gOpenCLExamples[i]);
|
||||
}
|
||||
#endif //B3_USE_CLEW
|
||||
}
|
||||
|
||||
void ExampleEntries::initExampleEntries()
|
||||
{
|
||||
m_data->m_allExamples.clear();
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
static void registerExampleEntry(int menuLevel, const char* name,const char* description, CommonExampleInterface::CreateFunc* createFunc, int option=0);
|
||||
|
||||
void initExampleEntries();
|
||||
|
||||
void initOpenCLExampleEntries();
|
||||
|
||||
int getNumRegisteredExamples();
|
||||
|
||||
|
||||
@@ -681,6 +681,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -33,7 +33,13 @@
|
||||
#include "../OpenGLWindow/SimpleOpenGL2Renderer.h"
|
||||
#include "ExampleEntries.h"
|
||||
#include "OpenGLGuiHelper.h"
|
||||
#include "Bullet3Common/b3FileUtils.h"
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
//quick test for file import, @todo(erwincoumans) make it more general and add other file formats
|
||||
#include "../Importers/ImportURDFDemo/ImportURDFSetup.h"
|
||||
#include "../Importers/ImportBullet/SerializeSetup.h"
|
||||
|
||||
static CommonGraphicsApp* s_app=0;
|
||||
|
||||
static CommonWindowInterface* s_window = 0;
|
||||
@@ -46,7 +52,7 @@ static MyProfileWindow* s_profWindow =0;
|
||||
const char* startFileName = "bulletDemo.txt";
|
||||
|
||||
static GwenUserInterface* gui = 0;
|
||||
static int sCurrentDemoIndex = 0;
|
||||
static int sCurrentDemoIndex = -1;
|
||||
static int sCurrentHightlighted = 0;
|
||||
static CommonExampleInterface* sCurrentDemo = 0;
|
||||
static b3AlignedObjectArray<const char*> allNames;
|
||||
@@ -58,11 +64,19 @@ extern bool useShadowMap;
|
||||
static bool visualWireframe=false;
|
||||
static bool renderVisualGeometry=true;
|
||||
static bool renderGrid = true;
|
||||
int gDebugDrawFlags = btIDebugDraw::DBG_DrawWireframe;
|
||||
int gDebugDrawFlags = 0;
|
||||
static bool pauseSimulation=false;
|
||||
int midiBaseIndex = 176;
|
||||
extern bool gDisableDeactivation;
|
||||
|
||||
///some quick test variable for the OpenCL examples
|
||||
|
||||
int gPreferredOpenCLDeviceIndex=-1;
|
||||
int gPreferredOpenCLPlatformIndex=-1;
|
||||
int gGpuArraySizeX=15;
|
||||
int gGpuArraySizeY=15;
|
||||
int gGpuArraySizeZ=15;
|
||||
|
||||
//#include <float.h>
|
||||
//unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM);
|
||||
|
||||
@@ -77,7 +91,7 @@ b3KeyboardCallback prevKeyboardCallback = 0;
|
||||
void MyKeyboardCallback(int key, int state)
|
||||
{
|
||||
|
||||
//printf("key=%d, state=%d\n", key, state);
|
||||
//b3Printf("key=%d, state=%d", key, state);
|
||||
bool handled = false;
|
||||
|
||||
if (gui && !handled )
|
||||
@@ -188,40 +202,65 @@ static void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void openURDFDemo(const char* filename)
|
||||
void openFileDemo(const char* filename)
|
||||
{
|
||||
#if 0
|
||||
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->exitPhysics();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
sCurrentDemo->exitPhysics();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
delete s_guiHelper;
|
||||
s_guiHelper = 0;
|
||||
}
|
||||
|
||||
|
||||
s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2);
|
||||
s_parameterInterface->removeAllParameters();
|
||||
|
||||
ImportUrdfSetup* physicsSetup = new ImportUrdfSetup();
|
||||
physicsSetup->setFileName(filename);
|
||||
|
||||
sCurrentDemo = new BasicDemo(s_app, physicsSetup);
|
||||
s_app->setUpAxis(2);
|
||||
CommonExampleOptions options(s_guiHelper,0);
|
||||
options.m_fileName = filename;
|
||||
|
||||
char fullPath[1024];
|
||||
int fileType = 0;
|
||||
sprintf(fullPath, "%s", filename);
|
||||
b3FileUtils::toLower(fullPath);
|
||||
if (strstr(fullPath, ".urdf"))
|
||||
{
|
||||
sCurrentDemo = ImportURDFCreateFunc(options);
|
||||
} else
|
||||
{
|
||||
if (strstr(fullPath, ".bullet"))
|
||||
{
|
||||
sCurrentDemo = SerializeBulletCreateFunc(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//physicsSetup->setFileName(filename);
|
||||
|
||||
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->initPhysics();
|
||||
sCurrentDemo->resetCamera();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void selectDemo(int demoIndex)
|
||||
{
|
||||
bool resetCamera = (sCurrentDemoIndex != demoIndex);
|
||||
sCurrentDemoIndex = demoIndex;
|
||||
sCurrentHightlighted = demoIndex;
|
||||
int numDemos = gAllExamples->getNumRegisteredExamples();
|
||||
|
||||
|
||||
|
||||
if (demoIndex>numDemos)
|
||||
{
|
||||
demoIndex = 0;
|
||||
@@ -241,7 +280,8 @@ void selectDemo(int demoIndex)
|
||||
s_parameterInterface->removeAllParameters();
|
||||
int option = gAllExamples->getExampleOption(demoIndex);
|
||||
s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2);
|
||||
sCurrentDemo = (*func)(0,s_guiHelper, option);
|
||||
CommonExampleOptions options(s_guiHelper, option);
|
||||
sCurrentDemo = (*func)(options);
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
if (gui)
|
||||
@@ -251,7 +291,12 @@ void selectDemo(int demoIndex)
|
||||
}
|
||||
b3Printf("Selected demo: %s",gAllExamples->getExampleName(demoIndex));
|
||||
gui->setExampleDescription(gAllExamples->getExampleDescription(demoIndex));
|
||||
|
||||
sCurrentDemo->initPhysics();
|
||||
if(resetCamera)
|
||||
{
|
||||
sCurrentDemo->resetCamera();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,13 +375,15 @@ void MyStatusBarPrintf(const char* msg)
|
||||
}
|
||||
|
||||
|
||||
void MyStatusBarWarning(const char* msg)
|
||||
void MyStatusBarError(const char* msg)
|
||||
{
|
||||
printf("Warning: %s\n", msg);
|
||||
if (gui)
|
||||
{
|
||||
bool isLeft = false;
|
||||
gui->setStatusBarMessage(msg,isLeft);
|
||||
gui->textOutput(msg);
|
||||
gui->forceUpdateScrollBars();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +499,7 @@ void fileOpenCallback()
|
||||
{
|
||||
//todo(erwincoumans) check if it is actually URDF
|
||||
//printf("file open:%s\n", filename);
|
||||
openURDFDemo(filename);
|
||||
openFileDemo(filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,20 +585,41 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
{
|
||||
b3CommandLineArgs args(argc,argv);
|
||||
|
||||
|
||||
///The OpenCL rigid body pipeline is experimental and
|
||||
///most OpenCL drivers and OpenCL compilers have issues with our kernels.
|
||||
///If you have a high-end desktop GPU such as AMD 7970 or better, or NVIDIA GTX 680 with up-to-date drivers
|
||||
///you could give it a try
|
||||
if (args.CheckCmdLineFlag("enable_experimental_opencl"))
|
||||
{
|
||||
gAllExamples->initOpenCLExampleEntries();
|
||||
}
|
||||
|
||||
|
||||
int width = 1024;
|
||||
int height=768;
|
||||
|
||||
SimpleOpenGL3App* simpleApp=0;
|
||||
sUseOpenGL2 =args.CheckCmdLineFlag("opengl2");
|
||||
|
||||
const char* appTitle = "Bullet Physics ExampleBrowser";
|
||||
#if defined (_DEBUG) || defined (DEBUG)
|
||||
const char* optMode = "Debug build (slow)";
|
||||
#else
|
||||
const char* optMode = "Release build";
|
||||
#endif
|
||||
|
||||
if (sUseOpenGL2 )
|
||||
{
|
||||
|
||||
s_app = new SimpleOpenGL2App("AllBullet2Demos",width,height);
|
||||
char title[1024];
|
||||
sprintf(title,"%s using limited OpenGL2 fallback. %s", appTitle,optMode);
|
||||
s_app = new SimpleOpenGL2App(title,width,height);
|
||||
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
|
||||
} else
|
||||
{
|
||||
simpleApp = new SimpleOpenGL3App("AllBullet2Demos",width,height);
|
||||
char title[1024];
|
||||
sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode);
|
||||
simpleApp = new SimpleOpenGL3App(title,width,height);
|
||||
s_app = simpleApp;
|
||||
}
|
||||
char* gVideoFileName = 0;
|
||||
@@ -575,9 +643,9 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
s_app->m_renderer->getActiveCamera()->setCameraPitch(0);
|
||||
s_app->m_renderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
|
||||
|
||||
b3SetCustomWarningMessageFunc(MyStatusBarWarning);
|
||||
//b3SetCustomPrintfFunc(MyStatusBarPrintf);
|
||||
b3SetCustomWarningMessageFunc(MyGuiPrintf);
|
||||
b3SetCustomPrintfFunc(MyGuiPrintf);
|
||||
b3SetCustomErrorMessageFunc(MyStatusBarError);
|
||||
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
@@ -647,14 +715,26 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
firstAvailableDemoIndex = d;
|
||||
firstNode = pNode;
|
||||
}
|
||||
|
||||
if (d == selectedDemo)
|
||||
{
|
||||
pNode->SetSelected(true);
|
||||
tree->ExpandAll();
|
||||
selectDemo(d);
|
||||
firstAvailableDemoIndex = d;
|
||||
firstNode = pNode;
|
||||
//pNode->SetSelected(true);
|
||||
//tree->ExpandAll();
|
||||
// tree->ForceUpdateScrollBars();
|
||||
//tree->OnKeyLeft(true);
|
||||
// tree->OnKeyRight(true);
|
||||
|
||||
|
||||
//tree->ExpandAll();
|
||||
|
||||
// selectDemo(d);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
MyMenuItemHander* handler = new MyMenuItemHander(d);
|
||||
pNode->onNamePress.Add(handler, &MyMenuItemHander::onButtonA);
|
||||
pNode->GetButton()->onDoubleClick.Add(handler, &MyMenuItemHander::onButtonB);
|
||||
@@ -679,7 +759,12 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
if (firstAvailableDemoIndex>=0)
|
||||
{
|
||||
firstNode->SetSelected(true);
|
||||
tree->ExpandAll();
|
||||
while (firstNode != tree)
|
||||
{
|
||||
firstNode->ExpandAll();
|
||||
firstNode = (Gwen::Controls::TreeNode*)firstNode->GetParent();
|
||||
}
|
||||
|
||||
selectDemo(firstAvailableDemoIndex);
|
||||
}
|
||||
|
||||
@@ -692,6 +777,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
}
|
||||
|
||||
gui->registerFileOpenCallback(fileOpenCallback);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -760,7 +846,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
||||
sCurrentDemo->stepSimulation(deltaTime);//1./60.f);
|
||||
}
|
||||
|
||||
if (renderVisualGeometry)
|
||||
if (renderVisualGeometry && ((gDebugDrawFlags&btIDebugDraw::DBG_DrawWireframe)==0))
|
||||
{
|
||||
if (visualWireframe)
|
||||
{
|
||||
@@ -770,11 +856,28 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
||||
sCurrentDemo->renderScene();
|
||||
}
|
||||
{
|
||||
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||
sCurrentDemo->physicsDebugDraw(gDebugDrawFlags);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
if (s_guiHelper && s_guiHelper->getRenderInterface() && s_guiHelper->getRenderInterface()->getActiveCamera())
|
||||
{
|
||||
char msg[1024];
|
||||
float camDist = s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraDistance();
|
||||
float pitch = s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraPitch();
|
||||
float yaw = s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraYaw();
|
||||
float camTarget[3];
|
||||
s_guiHelper->getRenderInterface()->getActiveCamera()->getCameraTargetPosition(camTarget);
|
||||
sprintf(msg,"dist=%f, pitch=%f, yaw=%f,target=%f,%f,%f", camDist,pitch,yaw,camTarget[0],camTarget[1],camTarget[2]);
|
||||
gui->setStatusBarMessage(msg, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int toggle = 1;
|
||||
if (1)
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
static btVector4 sColors[4] =
|
||||
{
|
||||
btVector4(0.3,0.3,1,1),
|
||||
btVector4(1,0,0,1),
|
||||
btVector4(0.6,0.6,1,1),
|
||||
btVector4(0,1,0,1),
|
||||
btVector4(0,1,1,1),
|
||||
//btVector4(1,1,0,1),
|
||||
@@ -128,7 +128,6 @@ struct OpenGLGuiHelperInternalData
|
||||
{
|
||||
struct CommonGraphicsApp* m_glApp;
|
||||
class MyDebugDrawer* m_debugDraw;
|
||||
int m_curColor;
|
||||
GL_ShapeDrawer* m_gl2ShapeDrawer;
|
||||
};
|
||||
|
||||
@@ -139,7 +138,7 @@ OpenGLGuiHelper::OpenGLGuiHelper(CommonGraphicsApp* glApp, bool useOpenGL2)
|
||||
m_data = new OpenGLGuiHelperInternalData;
|
||||
m_data->m_glApp = glApp;
|
||||
m_data->m_debugDraw = 0;
|
||||
m_data->m_curColor = 0;
|
||||
|
||||
m_data->m_gl2ShapeDrawer = 0;
|
||||
|
||||
if (useOpenGL2)
|
||||
@@ -487,15 +486,20 @@ void OpenGLGuiHelper::setUpAxis(int axis)
|
||||
m_data->m_glApp->setUpAxis(axis);
|
||||
}
|
||||
|
||||
|
||||
btVector3 OpenGLGuiHelper::selectColor()
|
||||
void OpenGLGuiHelper::resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ)
|
||||
{
|
||||
btVector4 color = sColors[m_data->m_curColor];
|
||||
m_data->m_curColor++;
|
||||
m_data->m_curColor&=3;
|
||||
return color;
|
||||
if (getRenderInterface() && getRenderInterface()->getActiveCamera())
|
||||
{
|
||||
getRenderInterface()->getActiveCamera()->setCameraDistance(camDist);
|
||||
getRenderInterface()->getActiveCamera()->setCameraPitch(pitch);
|
||||
getRenderInterface()->getActiveCamera()->setCameraYaw(yaw);
|
||||
getRenderInterface()->getActiveCamera()->setCameraTargetPosition(camPosX,camPosY,camPosZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct MyConvertPointerSizeT
|
||||
{
|
||||
union
|
||||
@@ -530,7 +534,9 @@ void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWor
|
||||
//btRigidBody* body = btRigidBody::upcast(colObj);
|
||||
//does this also work for btMultiBody/btMultiBodyLinkCollider?
|
||||
createCollisionShapeGraphicsObject(colObj->getCollisionShape());
|
||||
btVector3 color= selectColor();
|
||||
int colorIndex = colObj->getBroadphaseHandle()->getUid() & 3;
|
||||
|
||||
btVector3 color= sColors[colorIndex];
|
||||
createCollisionObjectGraphicsObject(colObj,color);
|
||||
|
||||
}
|
||||
@@ -546,3 +552,4 @@ struct CommonGraphicsApp* OpenGLGuiHelper::getAppInterface()
|
||||
{
|
||||
return m_data->m_glApp;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
||||
virtual void syncPhysicsToGraphics(const btDiscreteDynamicsWorld* rbWorld);
|
||||
|
||||
|
||||
|
||||
virtual void render(const btDiscreteDynamicsWorld* rbWorld);
|
||||
|
||||
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld);
|
||||
@@ -42,10 +41,9 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
||||
|
||||
virtual struct CommonGraphicsApp* getAppInterface();
|
||||
|
||||
|
||||
virtual void setUpAxis(int axis);
|
||||
|
||||
btVector3 selectColor();
|
||||
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ);
|
||||
|
||||
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) ;
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
"../Raycast/*",
|
||||
"../MultiBody/MultiDofDemo.cpp",
|
||||
"../MultiBody/TestJointTorqueSetup.cpp",
|
||||
"../ThirdPartyLibs/stb_image/*",
|
||||
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
|
||||
"../ThirdPartyLibs/tinyxml/*",
|
||||
"../Utils/b3Clock.*",
|
||||
@@ -92,7 +93,9 @@
|
||||
if (hasCL) then
|
||||
files {
|
||||
"../OpenCL/broadphase/*",
|
||||
"../OpenCL/CommonOpenCL/*"
|
||||
"../OpenCL/CommonOpenCL/*",
|
||||
"../OpenCL/rigidbody/GpuConvexScene.cpp",
|
||||
"../OpenCL/rigidbody/GpuRigidBodyDemo.cpp",
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -56,6 +56,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 10;
|
||||
float pitch = 62;
|
||||
float yaw = 33;
|
||||
float targetPos[3]={-3,2.4,-3.6};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -64,6 +72,7 @@ public:
|
||||
void ImplicitClothExample::initPhysics()
|
||||
{
|
||||
float size=10;
|
||||
m_guiHelper->setUpAxis(1);
|
||||
m_cloth = ClothCreate(numX,numY,size);
|
||||
|
||||
}
|
||||
@@ -114,7 +123,7 @@ void ImplicitClothExample::physicsDebugDraw(int debugFlags)
|
||||
}
|
||||
|
||||
|
||||
class CommonExampleInterface* ImplicitClothCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImplicitClothCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImplicitClothExample(helper, option);
|
||||
return new ImplicitClothExample(options.m_guiHelper, options.m_option);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef IMPLICIT_CLOTH_EXAMPLE_H
|
||||
#define IMPLICIT_CLOTH_EXAMPLE_H
|
||||
|
||||
class CommonExampleInterface* ImplicitClothCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImplicitClothCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPLICIT_CLOTH_EXAMPLE_H
|
||||
|
||||
@@ -141,6 +141,15 @@ class ForkLiftDemo : public CommonExampleInterface
|
||||
void initPhysics();
|
||||
void exitPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 8;
|
||||
float pitch = -45;
|
||||
float yaw = 32;
|
||||
float targetPos[3]={-0.33,-0.72,4.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
/*static DemoApplication* Create()
|
||||
{
|
||||
ForkLiftDemo* demo = new ForkLiftDemo();
|
||||
@@ -1200,7 +1209,7 @@ btRigidBody* ForkLiftDemo::localCreateRigidBody(btScalar mass, const btTransform
|
||||
return body;
|
||||
}
|
||||
|
||||
CommonExampleInterface* ForkLiftCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* ForkLiftCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ForkLiftDemo(helper);
|
||||
return new ForkLiftDemo(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef FORKLIFT_DEMO_H
|
||||
#define FORKLIFT_DEMO_H
|
||||
|
||||
class CommonExampleInterface* ForkLiftCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ForkLiftCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif // FORKLIFT_DEMO_H
|
||||
|
||||
|
||||
@@ -18,6 +18,15 @@ struct GyroscopicSetup : public CommonRigidBodyBase
|
||||
|
||||
virtual void physicsDebugDraw(int debugFlags);
|
||||
|
||||
void resetCamera()
|
||||
{
|
||||
float dist = 20;
|
||||
float pitch = 180;
|
||||
float yaw = 16;
|
||||
float targetPos[3]={-2.4,0.4,-0.24};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -123,7 +132,7 @@ void GyroscopicSetup::physicsDebugDraw(int debugFlags)
|
||||
}
|
||||
|
||||
|
||||
class CommonExampleInterface* GyroscopicCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* GyroscopicCreateFunc(CommonExampleOptions& options)
|
||||
{
|
||||
return new GyroscopicSetup(helper);
|
||||
return new GyroscopicSetup(options.m_guiHelper);
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
#ifndef GYROSCOPIC_SETUP_H
|
||||
#define GYROSCOPIC_SETUP_H
|
||||
|
||||
class CommonExampleInterface* GyroscopicCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* GyroscopicCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //GYROSCOPIC_SETUP_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
project "AppHelloWorld"
|
||||
project "App_HelloWorld"
|
||||
|
||||
if _OPTIONS["ios"] then
|
||||
kind "WindowedApp"
|
||||
|
||||
@@ -64,6 +64,14 @@ class BspDemo : public CommonRigidBodyBase
|
||||
|
||||
void initPhysics(const char* bspfilename);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 43;
|
||||
float pitch = -175;
|
||||
float yaw = 12;
|
||||
float targetPos[3]={4,-25,-6};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -277,9 +285,9 @@ char* makeExeToBspFilename(const char* lpCmdLine)
|
||||
}
|
||||
|
||||
|
||||
struct CommonExampleInterface* ImportBspCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
struct CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
BspDemo* demo = new BspDemo(helper);
|
||||
BspDemo* demo = new BspDemo(options.m_guiHelper);
|
||||
|
||||
demo->initPhysics("BspDemo.bsp");
|
||||
return demo;
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef BSP_DEMO_H
|
||||
#define BSP_DEMO_H
|
||||
|
||||
class CommonExampleInterface* ImportBspCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportBspCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //BSP_DEMO_H
|
||||
|
||||
@@ -6,19 +6,41 @@
|
||||
|
||||
class SerializeSetup : public CommonRigidBodyBase
|
||||
{
|
||||
|
||||
char m_fileName[1024];
|
||||
|
||||
public:
|
||||
SerializeSetup(struct GUIHelperInterface* helper);
|
||||
SerializeSetup(struct GUIHelperInterface* helper, const char* fileName);
|
||||
virtual ~SerializeSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
virtual void setFileName(const char* fileName)
|
||||
{
|
||||
memcpy(m_fileName,fileName,strlen(fileName)+1);
|
||||
}
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 9.5;
|
||||
float pitch = -2.8;
|
||||
float yaw = 20;
|
||||
float targetPos[3]={-0.2,-1.4,3.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
SerializeSetup::SerializeSetup(struct GUIHelperInterface* helper)
|
||||
SerializeSetup::SerializeSetup(struct GUIHelperInterface* helper, const char* fileName)
|
||||
:CommonRigidBodyBase(helper)
|
||||
{
|
||||
|
||||
if (fileName)
|
||||
{
|
||||
setFileName(fileName);
|
||||
} else
|
||||
{
|
||||
setFileName("spider.bullet");
|
||||
}
|
||||
}
|
||||
SerializeSetup::~SerializeSetup()
|
||||
{
|
||||
@@ -31,9 +53,9 @@ void SerializeSetup::initPhysics()
|
||||
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawContactPoints);
|
||||
btBulletWorldImporter* importer = new btBulletWorldImporter(m_dynamicsWorld);
|
||||
const char* someFileName="spider.bullet";
|
||||
|
||||
|
||||
const char* prefix[]={"./","./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
const char* prefix[]={"","./","./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
int numPrefixes = sizeof(prefix)/sizeof(const char*);
|
||||
char relativeFileName[1024];
|
||||
FILE* f=0;
|
||||
@@ -42,7 +64,7 @@ void SerializeSetup::initPhysics()
|
||||
|
||||
for (int i=0;!f && i<numPrefixes;i++)
|
||||
{
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],someFileName);
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],m_fileName);
|
||||
f = fopen(relativeFileName,"rb");
|
||||
if (f)
|
||||
{
|
||||
@@ -74,7 +96,7 @@ void SerializeSetup::initPhysics()
|
||||
btDefaultSerializer* serializer = new btDefaultSerializer();
|
||||
m_dynamicsWorld->serialize(serializer);
|
||||
|
||||
FILE* file = fopen("testFile.bullet","wb");
|
||||
FILE* file = fopen("SerializeSetupTestFile.bullet","wb");
|
||||
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
|
||||
fclose(file);
|
||||
|
||||
@@ -89,7 +111,7 @@ void SerializeSetup::stepSimulation(float deltaTime)
|
||||
CommonRigidBodyBase::stepSimulation(deltaTime);
|
||||
}
|
||||
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new SerializeSetup(helper);
|
||||
return new SerializeSetup(options.m_guiHelper, options.m_fileName);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SERIALIZE_SETUP_H
|
||||
#define SERIALIZE_SETUP_H
|
||||
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* SerializeBulletCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //SERIALIZE_SETUP_H
|
||||
|
||||
@@ -37,6 +37,15 @@ public:
|
||||
virtual ~ImportColladaSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 16;
|
||||
float pitch = -140;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={-4,-3,-3};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ImportColladaSetup::ImportColladaSetup(struct GUIHelperInterface* helper)
|
||||
@@ -197,7 +206,7 @@ void ImportColladaSetup::initPhysics()
|
||||
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportColladaSetup(helper);
|
||||
return new ImportColladaSetup(options.m_guiHelper);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
||||
#ifndef IMPORT_COLLADA_SETUP_H
|
||||
#define IMPORT_COLLADA_SETUP_H
|
||||
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportColladaCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_COLLADA_SETUP_H
|
||||
|
||||
@@ -19,6 +19,16 @@ public:
|
||||
virtual ~ImportObjSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 50;
|
||||
float pitch = 61;
|
||||
float yaw = 18;
|
||||
float targetPos[3]={-15,-15,47};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
ImportObjSetup::ImportObjSetup(struct GUIHelperInterface* helper)
|
||||
@@ -99,7 +109,7 @@ void ImportObjSetup::initPhysics()
|
||||
}
|
||||
}
|
||||
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportObjSetup(helper);
|
||||
return new ImportObjSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef IMPORT_OBJ_EXAMPLE_H
|
||||
#define IMPORT_OBJ_EXAMPLE_H
|
||||
|
||||
class CommonExampleInterface* ImportObjCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportObjCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_OBJ_EXAMPLE_H
|
||||
|
||||
@@ -18,6 +18,15 @@ public:
|
||||
virtual ~ImportSTLSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.5;
|
||||
float pitch = -136;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={0.47,0,-0.64};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -92,7 +101,7 @@ void ImportSTLSetup::initPhysics()
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new ImportSTLSetup(helper);
|
||||
return new ImportSTLSetup(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef IMPORT_STL_SETUP_H
|
||||
#define IMPORT_STL_SETUP_H
|
||||
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportSTLCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //IMPORT_OBJ_SETUP_H
|
||||
|
||||
@@ -34,13 +34,22 @@ class ImportUrdfSetup : public CommonMultiBodyBase
|
||||
bool m_useMultiBody;
|
||||
|
||||
public:
|
||||
ImportUrdfSetup(struct GUIHelperInterface* helper, int option);
|
||||
ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName);
|
||||
virtual ~ImportUrdfSetup();
|
||||
|
||||
virtual void initPhysics();
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
void setFileName(const char* urdfFileName);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.5;
|
||||
float pitch = -136;
|
||||
float yaw = 28;
|
||||
float targetPos[3]={0.47,0,-0.64};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,9 +71,11 @@ struct ImportUrdfInternalData
|
||||
};
|
||||
|
||||
|
||||
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option)
|
||||
ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option, const char* fileName)
|
||||
:CommonMultiBodyBase(helper)
|
||||
{
|
||||
m_data = new ImportUrdfInternalData;
|
||||
|
||||
if (option==1)
|
||||
{
|
||||
m_useMultiBody = true;
|
||||
@@ -74,38 +85,44 @@ ImportUrdfSetup::ImportUrdfSetup(struct GUIHelperInterface* helper, int option)
|
||||
}
|
||||
|
||||
static int count = 0;
|
||||
gFileNameArray.clear();
|
||||
gFileNameArray.push_back("r2d2.urdf");
|
||||
|
||||
m_data = new ImportUrdfInternalData;
|
||||
|
||||
//load additional urdf file names from file
|
||||
|
||||
FILE* f = fopen("urdf_files.txt","r");
|
||||
if (f)
|
||||
{
|
||||
int result;
|
||||
//warning: we don't avoid string buffer overflow in this basic example in fscanf
|
||||
char fileName[1024];
|
||||
do
|
||||
{
|
||||
result = fscanf(f,"%s",fileName);
|
||||
if (result==1)
|
||||
{
|
||||
gFileNameArray.push_back(fileName);
|
||||
}
|
||||
} while (result==1);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int numFileNames = gFileNameArray.size();
|
||||
|
||||
if (count>=numFileNames)
|
||||
if (fileName)
|
||||
{
|
||||
count=0;
|
||||
setFileName(fileName);
|
||||
} else
|
||||
{
|
||||
gFileNameArray.clear();
|
||||
gFileNameArray.push_back("r2d2.urdf");
|
||||
|
||||
|
||||
|
||||
//load additional urdf file names from file
|
||||
|
||||
FILE* f = fopen("urdf_files.txt","r");
|
||||
if (f)
|
||||
{
|
||||
int result;
|
||||
//warning: we don't avoid string buffer overflow in this basic example in fscanf
|
||||
char fileName[1024];
|
||||
do
|
||||
{
|
||||
result = fscanf(f,"%s",fileName);
|
||||
if (result==1)
|
||||
{
|
||||
gFileNameArray.push_back(fileName);
|
||||
}
|
||||
} while (result==1);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int numFileNames = gFileNameArray.size();
|
||||
|
||||
if (count>=numFileNames)
|
||||
{
|
||||
count=0;
|
||||
}
|
||||
sprintf(m_fileName,gFileNameArray[count++].c_str());
|
||||
}
|
||||
sprintf(m_fileName,gFileNameArray[count++].c_str());
|
||||
}
|
||||
|
||||
ImportUrdfSetup::~ImportUrdfSetup()
|
||||
@@ -270,8 +287,8 @@ void ImportUrdfSetup::stepSimulation(float deltaTime)
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
|
||||
return new ImportUrdfSetup(helper, option);
|
||||
return new ImportUrdfSetup(options.m_guiHelper, options.m_option,options.m_fileName);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#define IMPORT_URDF_SETUP_H
|
||||
|
||||
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* ImportURDFCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //IMPORT_URDF_SETUP_H
|
||||
|
||||
@@ -29,6 +29,15 @@ public:
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 1;
|
||||
float pitch = 50;
|
||||
float yaw = 35;
|
||||
float targetPos[3]={-3,2.8,-2.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
btMultiBody* createFeatherstoneMultiBody_testMultiDof(class btMultiBodyDynamicsWorld* world, int numLinks, const btVector3& basePosition, const btVector3 &baseHalfExtents, const btVector3 &linkHalfExtents, bool spherical = false, bool floating = false);
|
||||
void addColliders_testMultiDof(btMultiBody *pMultiBody, btMultiBodyDynamicsWorld *pWorld, const btVector3 &baseHalfExtents, const btVector3 &linkHalfExtents);
|
||||
@@ -76,6 +85,7 @@ void MultiDofDemo::stepSimulation(float deltaTime)
|
||||
void MultiDofDemo::initPhysics()
|
||||
{
|
||||
|
||||
|
||||
m_guiHelper->setUpAxis(1);
|
||||
|
||||
if(g_firstInit)
|
||||
@@ -100,7 +110,7 @@ void MultiDofDemo::initPhysics()
|
||||
btMultiBodyDynamicsWorld* world = new btMultiBodyDynamicsWorld(m_dispatcher,m_broadphase,sol,m_collisionConfiguration);
|
||||
m_dynamicsWorld = world;
|
||||
// m_dynamicsWorld->setDebugDrawer(&gDebugDraw);
|
||||
|
||||
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||
|
||||
///create a few basic rigid bodies
|
||||
@@ -418,7 +428,7 @@ void MultiDofDemo::addBoxes_testMultiDof()
|
||||
}
|
||||
}
|
||||
|
||||
class CommonExampleInterface* MultiDofCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* MultiDofCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new MultiDofDemo(helper);
|
||||
return new MultiDofDemo(options.m_guiHelper);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef MULTI_DOF_DEMO_H
|
||||
#define MULTI_DOF_DEMO_H
|
||||
|
||||
class CommonExampleInterface* MultiDofCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* MultiDofCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //MULTI_DOF_DEMO_H
|
||||
|
||||
|
||||
@@ -18,6 +18,16 @@ public:
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 5;
|
||||
float pitch = 270;
|
||||
float yaw = 21;
|
||||
float targetPos[3]={-1.34,3.4,-0.44};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
TestJointTorqueSetup::TestJointTorqueSetup(struct GUIHelperInterface* helper)
|
||||
@@ -270,7 +280,7 @@ void TestJointTorqueSetup::stepSimulation(float deltaTime)
|
||||
}
|
||||
|
||||
|
||||
class CommonExampleInterface* TestJointTorqueCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* TestJointTorqueCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new TestJointTorqueSetup(helper);
|
||||
return new TestJointTorqueSetup(options.m_guiHelper);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TEST_JOINT_TORQUE_SETUP_H
|
||||
#define TEST_JOINT_TORQUE_SETUP_H
|
||||
|
||||
class CommonExampleInterface* TestJointTorqueCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* TestJointTorqueCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //TEST_JOINT_TORQUE_SETUP_H
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "pairsKernel.h"
|
||||
|
||||
extern int gPreferredOpenCLDeviceIndex;
|
||||
extern int gPreferredOpenCLPlatformIndex;
|
||||
|
||||
|
||||
#include "../CommonInterfaces/CommonExampleInterface.h"
|
||||
#include "../CommonInterfaces/CommonGUIHelperInterface.h"
|
||||
@@ -32,14 +35,13 @@
|
||||
#include "../OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
|
||||
|
||||
char* gPairBenchFileName = 0;
|
||||
|
||||
class PairBench : public CommonOpenCLBase
|
||||
{
|
||||
|
||||
struct PairBenchInternalData* m_data;
|
||||
|
||||
GLInstancingRenderer* m_instancingRenderer;
|
||||
|
||||
public:
|
||||
|
||||
PairBench(GUIHelperInterface* helper);
|
||||
@@ -56,6 +58,24 @@ public:
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
virtual void renderScene();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 10;
|
||||
|
||||
if (gPairBenchFileName)
|
||||
{
|
||||
dist = 830;
|
||||
} else
|
||||
{
|
||||
dist = 130;
|
||||
}
|
||||
|
||||
float pitch = 62;
|
||||
float yaw = 33;
|
||||
float targetPos[4]={15.5,12.5,15.5,0};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -67,7 +87,7 @@ public:
|
||||
|
||||
|
||||
|
||||
char* gPairBenchFileName = 0;
|
||||
|
||||
extern bool useShadowMap;
|
||||
float maxExtents = -1e30f;
|
||||
int largeCount = 0;
|
||||
@@ -143,7 +163,8 @@ PairBench::PairBench(GUIHelperInterface* helper)
|
||||
:CommonOpenCLBase(helper)
|
||||
{
|
||||
m_data = new PairBenchInternalData;
|
||||
m_instancingRenderer = (GLInstancingRenderer*) helper->getRenderInterface();
|
||||
|
||||
|
||||
m_data->m_validationBroadphase = 0;
|
||||
}
|
||||
PairBench::~PairBench()
|
||||
@@ -182,17 +203,15 @@ void PairBench::initPhysics()
|
||||
dimensions[1] = 10;
|
||||
dimensions[2] = 10;
|
||||
|
||||
//m_instancingRenderer = ci.m_instancingRenderer;
|
||||
//m_guiHelper->getRenderInterface() = ci.m_guiHelper->getRenderInterface();
|
||||
sPairDemo = this;
|
||||
useShadowMap = false;
|
||||
|
||||
|
||||
int startItem = 0;
|
||||
|
||||
int preferredOpenCLDeviceIndex=-1;
|
||||
int preferredOpenCLPlatformIndex=-1;
|
||||
|
||||
initCL(preferredOpenCLDeviceIndex,preferredOpenCLPlatformIndex);
|
||||
|
||||
initCL(gPreferredOpenCLDeviceIndex,gPreferredOpenCLPlatformIndex);
|
||||
|
||||
if (m_clData->m_clContext)
|
||||
{
|
||||
@@ -228,7 +247,7 @@ void PairBench::createBroadphase(int arraySizeX, int arraySizeY, int arraySizeZ)
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_vertices)/sizeof(int);
|
||||
int shapeId = m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = m_guiHelper->getRenderInterface()->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=TEST_INDEX_OFFSET;
|
||||
@@ -316,12 +335,12 @@ void PairBench::createBroadphase(int arraySizeX, int arraySizeY, int arraySizeZ)
|
||||
if (l>500)
|
||||
{
|
||||
b3Vector4 color=b3MakeVector4(0,1,0,0.1);
|
||||
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int id = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
m_data->m_broadphaseGPU->createLargeProxy(aabbMin,aabbMax,index,group,mask);
|
||||
} else
|
||||
{
|
||||
b3Vector4 color=b3MakeVector4(1,0,0,1);
|
||||
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int id = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
m_data->m_broadphaseGPU->createProxy(aabbMin,aabbMax,index,group,mask);
|
||||
index++;
|
||||
}
|
||||
@@ -384,7 +403,7 @@ void PairBench::createBroadphase(int arraySizeX, int arraySizeY, int arraySizeZ)
|
||||
}*/
|
||||
|
||||
|
||||
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int id = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
|
||||
|
||||
b3Vector3 aabbMin = position-scaling;
|
||||
@@ -404,21 +423,13 @@ void PairBench::createBroadphase(int arraySizeX, int arraySizeY, int arraySizeZ)
|
||||
}
|
||||
}
|
||||
|
||||
float camPos[4]={15.5,12.5,15.5,0};
|
||||
m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(camPos[0],camPos[1],camPos[2]);
|
||||
if (gPairBenchFileName)
|
||||
{
|
||||
m_instancingRenderer->getActiveCamera()->setCameraDistance(830);
|
||||
} else
|
||||
{
|
||||
m_instancingRenderer->getActiveCamera()->setCameraDistance(130);
|
||||
}
|
||||
|
||||
m_instancingRenderer->writeTransforms();
|
||||
m_guiHelper->getRenderInterface()->writeTransforms();
|
||||
m_data->m_broadphaseGPU->writeAabbsToGpu();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PairBench::deleteBroadphase()
|
||||
{
|
||||
delete m_data->m_broadphaseGPU;
|
||||
@@ -429,11 +440,13 @@ void PairBench::deleteBroadphase()
|
||||
m_data->m_bodyTimes = 0;
|
||||
|
||||
m_data->m_broadphaseGPU = 0;
|
||||
m_instancingRenderer->removeAllInstances();
|
||||
m_guiHelper->getRenderInterface()->removeAllInstances();
|
||||
}
|
||||
|
||||
void PairBench::exitPhysics()
|
||||
{
|
||||
//reset the state to 'on'
|
||||
useShadowMap = true;
|
||||
if(m_data->m_validationBroadphase)
|
||||
{
|
||||
delete m_data->m_validationBroadphase;
|
||||
@@ -449,7 +462,7 @@ void PairBench::exitPhysics()
|
||||
|
||||
void PairBench::renderScene()
|
||||
{
|
||||
m_instancingRenderer->renderScene();
|
||||
m_guiHelper->getRenderInterface()->renderScene();
|
||||
}
|
||||
|
||||
struct OverlappingPairSortPredicate
|
||||
@@ -467,17 +480,23 @@ void PairBench::stepSimulation(float deltaTime)
|
||||
{
|
||||
//color all objects blue
|
||||
|
||||
GLInstanceRendererInternalData* internalData = m_guiHelper->getRenderInterface()->getInternalData();
|
||||
|
||||
if (internalData==0)
|
||||
return;
|
||||
|
||||
|
||||
bool animate=true;
|
||||
int numObjects= 0;
|
||||
{
|
||||
B3_PROFILE("Num Objects");
|
||||
numObjects = m_instancingRenderer->getInternalData()->m_totalNumInstances;
|
||||
numObjects = internalData->m_totalNumInstances;
|
||||
}
|
||||
b3Vector4* positions = 0;
|
||||
if (numObjects)
|
||||
{
|
||||
B3_PROFILE("Sync");
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
GLuint vbo = internalData->m_vbo;
|
||||
|
||||
|
||||
|
||||
@@ -488,7 +507,7 @@ void PairBench::stepSimulation(float deltaTime)
|
||||
char* hostPtr= 0;
|
||||
{
|
||||
B3_PROFILE("glMapBufferRange");
|
||||
hostPtr = (char*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_WRITE_BIT|GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
hostPtr = (char*)glMapBufferRange( GL_ARRAY_BUFFER,internalData->m_maxShapeCapacityInBytes,arraySizeInBytes, GL_MAP_WRITE_BIT|GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
}
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
@@ -767,7 +786,7 @@ void PairBench::stepSimulation(float deltaTime)
|
||||
|
||||
}
|
||||
|
||||
class CommonExampleInterface* PairBenchOpenCLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* PairBenchOpenCLCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new PairBench(helper);
|
||||
return new PairBench(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef PAIR_BENCH_H
|
||||
#define PAIR_BENCH_H
|
||||
|
||||
class CommonExampleInterface* PairBenchOpenCLCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* PairBenchOpenCLCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
758
examples/OpenCL/rigidbody/ConcaveScene.cpp
Normal file
758
examples/OpenCL/rigidbody/ConcaveScene.cpp
Normal file
@@ -0,0 +1,758 @@
|
||||
#include "ConcaveScene.h"
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include"../../Wavefront/tiny_obj_loader.h"
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3ConvexUtility.h"
|
||||
|
||||
#include "Bullet3AppSupport/gwenUserInterface.h"
|
||||
#include "OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
#define CONCAVE_GAPX 14
|
||||
#define CONCAVE_GAPY 5
|
||||
#define CONCAVE_GAPZ 14
|
||||
|
||||
GLInstanceGraphicsShape* createGraphicsShapeFromWavefrontObj(std::vector<tinyobj::shape_t>& shapes)
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex>* vertices = new b3AlignedObjectArray<GLInstanceVertex>;
|
||||
{
|
||||
// int numVertices = obj->vertexCount;
|
||||
// int numIndices = 0;
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
|
||||
for (int s=0;s<shapes.size();s++)
|
||||
{
|
||||
tinyobj::shape_t& shape = shapes[s];
|
||||
int faceCount = shape.mesh.indices.size();
|
||||
|
||||
|
||||
for (int f=0;f<faceCount;f+=3)
|
||||
{
|
||||
|
||||
//b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (1)
|
||||
{
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
int vtxBaseIndex = vertices->size();
|
||||
|
||||
|
||||
indicesPtr->push_back(vtxBaseIndex);
|
||||
indicesPtr->push_back(vtxBaseIndex+1);
|
||||
indicesPtr->push_back(vtxBaseIndex+2);
|
||||
|
||||
GLInstanceVertex vtx0;
|
||||
vtx0.xyzw[0] = shape.mesh.positions[shape.mesh.indices[f]*3+0];
|
||||
vtx0.xyzw[1] = shape.mesh.positions[shape.mesh.indices[f]*3+1];
|
||||
vtx0.xyzw[2] = shape.mesh.positions[shape.mesh.indices[f]*3+2];
|
||||
vtx0.xyzw[3] = 0.f;
|
||||
|
||||
vtx0.uv[0] = 0.5f;//shape.mesh.positions[shape.mesh.indices[f]*3+2];?
|
||||
vtx0.uv[1] = 0.5f;
|
||||
|
||||
GLInstanceVertex vtx1;
|
||||
vtx1.xyzw[0] = shape.mesh.positions[shape.mesh.indices[f+1]*3+0];
|
||||
vtx1.xyzw[1] = shape.mesh.positions[shape.mesh.indices[f+1]*3+1];
|
||||
vtx1.xyzw[2] = shape.mesh.positions[shape.mesh.indices[f+1]*3+2];
|
||||
vtx1.xyzw[3]= 0.f;
|
||||
vtx1.uv[0] = 0.5f;//obj->textureList[face->vertex_index[1]]->e[0];
|
||||
vtx1.uv[1] = 0.5f;//obj->textureList[face->vertex_index[1]]->e[1];
|
||||
|
||||
GLInstanceVertex vtx2;
|
||||
vtx2.xyzw[0] = shape.mesh.positions[shape.mesh.indices[f+2]*3+0];
|
||||
vtx2.xyzw[1] = shape.mesh.positions[shape.mesh.indices[f+2]*3+1];
|
||||
vtx2.xyzw[2] = shape.mesh.positions[shape.mesh.indices[f+2]*3+2];
|
||||
vtx2.xyzw[3] = 0.f;
|
||||
vtx2.uv[0] = 0.5f;
|
||||
vtx2.uv[1] = 0.5f;
|
||||
|
||||
|
||||
b3Vector3 v0=b3MakeVector3(vtx0.xyzw[0],vtx0.xyzw[1],vtx0.xyzw[2]);
|
||||
b3Vector3 v1=b3MakeVector3(vtx1.xyzw[0],vtx1.xyzw[1],vtx1.xyzw[2]);
|
||||
b3Vector3 v2=b3MakeVector3(vtx2.xyzw[0],vtx2.xyzw[1],vtx2.xyzw[2]);
|
||||
|
||||
normal = (v1-v0).cross(v2-v0);
|
||||
normal.normalize();
|
||||
vtx0.normal[0] = normal[0];
|
||||
vtx0.normal[1] = normal[1];
|
||||
vtx0.normal[2] = normal[2];
|
||||
vtx1.normal[0] = normal[0];
|
||||
vtx1.normal[1] = normal[1];
|
||||
vtx1.normal[2] = normal[2];
|
||||
vtx2.normal[0] = normal[0];
|
||||
vtx2.normal[1] = normal[1];
|
||||
vtx2.normal[2] = normal[2];
|
||||
vertices->push_back(vtx0);
|
||||
vertices->push_back(vtx1);
|
||||
vertices->push_back(vtx2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLInstanceGraphicsShape* gfxShape = new GLInstanceGraphicsShape;
|
||||
gfxShape->m_vertices = vertices;
|
||||
gfxShape->m_numvertices = vertices->size();
|
||||
gfxShape->m_indices = indicesPtr;
|
||||
gfxShape->m_numIndices = indicesPtr->size();
|
||||
for (int i=0;i<4;i++)
|
||||
gfxShape->m_scaling[i] = 1;//bake the scaling into the vertices
|
||||
return gfxShape;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fileName, const b3Vector3& shift, const b3Vector3& scaling)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
char relativeFileName[1024];
|
||||
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
int prefixIndex=-1;
|
||||
{
|
||||
|
||||
int numPrefixes = sizeof(prefix)/sizeof(char*);
|
||||
|
||||
for (int i=0;i<numPrefixes;i++)
|
||||
{
|
||||
FILE* f = 0;
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],fileName);
|
||||
f = fopen(relativeFileName,"r");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
prefixIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixIndex<0)
|
||||
return;
|
||||
|
||||
|
||||
int index=10;
|
||||
|
||||
{
|
||||
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::string err = tinyobj::LoadObj(shapes, relativeFileName, prefix[prefixIndex]);
|
||||
|
||||
GLInstanceGraphicsShape* shape = createGraphicsShapeFromWavefrontObj(shapes);
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
for (int i=0;i<shape->m_numvertices;i++)
|
||||
{
|
||||
for (int j=0;j<3;j++)
|
||||
shape->m_vertices->at(i).xyzw[j] += shift[j];
|
||||
|
||||
b3Vector3 vtx=b3MakeVector3(shape->m_vertices->at(i).xyzw[0],
|
||||
shape->m_vertices->at(i).xyzw[1],
|
||||
shape->m_vertices->at(i).xyzw[2]);
|
||||
verts.push_back(vtx*scaling);
|
||||
}
|
||||
|
||||
int colIndex = m_data->m_np->registerConcaveMesh(&verts,shape->m_indices,b3MakeVector3(1,1,1));
|
||||
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&shape->m_vertices->at(0).xyzw[0], shape->m_numvertices, &shape->m_indices->at(0), shape->m_numIndices);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0.3,0.3,1,1.f);//0.5);//1.f
|
||||
|
||||
|
||||
{
|
||||
float mass = 0.f;
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
delete shape->m_indices;
|
||||
delete shape->m_vertices;
|
||||
delete shape;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ConcaveScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
if (1)
|
||||
{
|
||||
|
||||
//char* fileName = "slopedPlane100.obj";
|
||||
//char* fileName = "plane100.obj";
|
||||
// char* fileName = "plane100.obj";
|
||||
|
||||
//char* fileName = "teddy.obj";//"plane.obj";
|
||||
// char* fileName = "sponza_closed.obj";//"plane.obj";
|
||||
//char* fileName = "leoTest1.obj";
|
||||
const char* fileName = "samurai_monastry.obj";
|
||||
// char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
|
||||
b3Vector3 shift1=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
|
||||
|
||||
b3Vector4 scaling=b3MakeVector4(10,10,10,1);
|
||||
|
||||
// createConcaveMesh(ci,"plane100.obj",shift1,scaling);
|
||||
//createConcaveMesh(ci,"plane100.obj",shift,scaling);
|
||||
|
||||
// b3Vector3 shift2(0,0,0);//0,230,80);//150,-100,-120);
|
||||
// createConcaveMesh(ci,"teddy.obj",shift2,scaling);
|
||||
|
||||
// b3Vector3 shift3(130,-150,-75);//0,230,80);//150,-100,-120);
|
||||
// createConcaveMesh(ci,"leoTest1.obj",shift3,scaling);
|
||||
createConcaveMesh(ci,fileName,shift1,scaling);
|
||||
|
||||
} else
|
||||
{
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
{
|
||||
b3Vector4 scaling=b3MakeVector4(400,1.,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,-2,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
createDynamicObjects(ci);
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
|
||||
float camPos[4]={0,0,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraPitch(45);
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(355);
|
||||
char msg[1024];
|
||||
int numInstances = m_data->m_rigidBodyPipeline->getNumBodies();
|
||||
sprintf(msg,"Num objects = %d",numInstances);
|
||||
if (ci.m_gui)
|
||||
ci.m_gui->setStatusBarMessage(msg,true);
|
||||
|
||||
}
|
||||
|
||||
void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
|
||||
|
||||
int index=0;
|
||||
|
||||
|
||||
if (1)
|
||||
{
|
||||
int curColor = 0;
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,1,1,1),
|
||||
b3MakeVector4(1,1,0.3,1),
|
||||
b3MakeVector4(0.3,1,1,1),
|
||||
b3MakeVector4(0.3,0.3,1,1),
|
||||
};
|
||||
|
||||
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
|
||||
{
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
|
||||
unsigned char* vts = (unsigned char*) cube_vertices;
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3MakeVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
if (numVertices)
|
||||
{
|
||||
utilPtr->initializePolyhedralFeatures(&verts[0],verts.size(),merge);
|
||||
}
|
||||
}
|
||||
|
||||
// int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
int colIndex=-1;
|
||||
if (ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
if (!ci.m_useInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
float mass = 1;
|
||||
|
||||
//b3Vector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ);
|
||||
b3Vector3 position=b3MakeVector3(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,
|
||||
23+j*CONCAVE_GAPY,
|
||||
-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConcaveCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
ConcaveScene::setupScene(ci);
|
||||
|
||||
float camPos[4]={0,50,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraPitch(45);
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(40);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ConcaveCompound2Scene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
const char* fileName = "teddy2_VHACD_CHs.obj";
|
||||
//char* fileName = "cube_offset.obj";
|
||||
|
||||
|
||||
b3Vector3 shift=b3MakeVector3(0,0,0);//0,230,80);//150,-100,-120);
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
const char* prefix[]={"./data/","../data/","../../data/","../../../data/","../../../../data/"};
|
||||
int prefixIndex=-1;
|
||||
|
||||
char relativeFileName[1024];
|
||||
{
|
||||
|
||||
int numPrefixes = sizeof(prefix)/sizeof(char*);
|
||||
|
||||
for (int i=0;i<numPrefixes;i++)
|
||||
{
|
||||
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],fileName);
|
||||
FILE* f = 0;
|
||||
f = fopen(relativeFileName,"r");
|
||||
if (f)
|
||||
{
|
||||
prefixIndex = i;
|
||||
fclose(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixIndex<0)
|
||||
return;
|
||||
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::string err = tinyobj::LoadObj(shapes, relativeFileName, prefix[prefixIndex]);
|
||||
|
||||
|
||||
if (shapes.size()>0)
|
||||
{
|
||||
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
b3AlignedObjectArray<int> indexArray;
|
||||
|
||||
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
int colIndex = 0;
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertices;
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
|
||||
{
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
|
||||
int numChildShapes = shapes.size();
|
||||
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
// int i=4;
|
||||
{
|
||||
tinyobj::shape_t& shape = shapes[i];
|
||||
|
||||
int numVertices = shape.mesh.positions.size()/3;
|
||||
int numFaces = shape.mesh.indices.size()/3;
|
||||
|
||||
|
||||
|
||||
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
|
||||
b3Vector3 pos=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
child.m_childPosition[v] = pos[v];
|
||||
child.m_childOrientation[v] = orn[v];
|
||||
}
|
||||
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(pos);
|
||||
tr.setRotation(orn);
|
||||
|
||||
int baseIndex = vertexArray.size();
|
||||
|
||||
for (int f=0;f<numFaces;f++)
|
||||
{
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
indexArray.push_back(baseIndex+shape.mesh.indices[f*3+i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
b3Vector3 center=b3MakeVector3(0,0,0);
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> tmpVertices;
|
||||
//add transformed graphics vertices and indices
|
||||
b3Vector3 myScaling=b3MakeVector3(50,50,50);//300,300,300);
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert;
|
||||
|
||||
|
||||
|
||||
vert.uv[0] = 0.5f;
|
||||
vert.uv[1] = 0.5f;
|
||||
vert.normal[0]=0.f;
|
||||
vert.normal[1]=1.f;
|
||||
vert.normal[2]=0.f;
|
||||
b3Vector3 vertPos;
|
||||
vertPos[0] = shape.mesh.positions[v*3+0]*myScaling[0];
|
||||
vertPos[1] = shape.mesh.positions[v*3+1]*myScaling[1];
|
||||
vertPos[2] = shape.mesh.positions[v*3+2]*myScaling[2];
|
||||
vertPos[3] =0.f;
|
||||
center+=vertPos;
|
||||
}
|
||||
|
||||
center/=numVertices;
|
||||
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert;
|
||||
vert.uv[0] = 0.5f;
|
||||
vert.uv[1] = 0.5f;
|
||||
vert.normal[0]=0.f;
|
||||
vert.normal[1]=1.f;
|
||||
vert.normal[2]=0.f;
|
||||
b3Vector3 vertPos;
|
||||
vertPos[0] = shape.mesh.positions[v*3+0]*myScaling[0];
|
||||
vertPos[1] = shape.mesh.positions[v*3+1]*myScaling[1];
|
||||
vertPos[2] = shape.mesh.positions[v*3+2]*myScaling[2];
|
||||
vertPos[3] =0.f;
|
||||
// vertPos-=center;
|
||||
vert.xyzw[0] = vertPos[0];
|
||||
vert.xyzw[1] = vertPos[1];
|
||||
vert.xyzw[2] = vertPos[2];
|
||||
|
||||
tmpVertices.push_back(vert);
|
||||
b3Vector3 newPos = tr*vertPos;
|
||||
vert.xyzw[0] = newPos[0];
|
||||
vert.xyzw[1] = newPos[1];
|
||||
vert.xyzw[2] = newPos[2];
|
||||
vert.xyzw[3] = 0.f;
|
||||
vertexArray.push_back(vert);
|
||||
}
|
||||
|
||||
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&tmpVertices[0].xyzw[0],strideInBytes,numVertices, scaling);
|
||||
child.m_shapeIndex = childColIndex;
|
||||
childShapes.push_back(child);
|
||||
colIndex = childColIndex;
|
||||
}
|
||||
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
|
||||
|
||||
}
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
for (int i=0;i<1;i++)//ci.arraySizeX;i++)
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
{
|
||||
// for (int k=0;k<ci.arraySizeZ;k++)
|
||||
int k=0;
|
||||
{
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
//b3Vector3 position(i*10*ci.gapX,j*ci.gapY,k*10*ci.gapZ);
|
||||
b3Vector3 position=b3MakeVector3(i*10*ci.gapX,10+j*10*ci.gapY,k*10*ci.gapZ);
|
||||
|
||||
// b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(0,0,1),1.8);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConcaveCompoundScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
b3AlignedObjectArray<int> indexArray;
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
float scaling[4] = {1,1,1,1};
|
||||
int colIndex = 0;
|
||||
|
||||
GLInstanceVertex* cubeVerts = (GLInstanceVertex*)&cube_vertices[0];
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
|
||||
{
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
|
||||
b3Vector3 childPositions[3] = {
|
||||
b3MakeVector3(0,-2,0),
|
||||
b3MakeVector3(0,0,0),
|
||||
b3MakeVector3(0,0,2)
|
||||
};
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
int numChildShapes = 3;
|
||||
for (int i=0;i<numChildShapes;i++)
|
||||
{
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = childColIndex;
|
||||
b3Vector3 pos = childPositions[i];
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
child.m_childPosition[v] = pos[v];
|
||||
child.m_childOrientation[v] = orn[v];
|
||||
}
|
||||
childShapes.push_back(child);
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(pos);
|
||||
tr.setRotation(orn);
|
||||
|
||||
int baseIndex = vertexArray.size();
|
||||
for (int j=0;j<numIndices;j++)
|
||||
indexArray.push_back(cube_indices[j]+baseIndex);
|
||||
|
||||
//add transformed graphics vertices and indices
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert = cubeVerts[v];
|
||||
b3Vector3 vertPos=b3MakeVector3(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 newPos = tr*vertPos;
|
||||
vert.xyzw[0] = newPos[0];
|
||||
vert.xyzw[1] = newPos[1];
|
||||
vert.xyzw[2] = newPos[2];
|
||||
vert.xyzw[3] = 0.f;
|
||||
vertexArray.push_back(vert);
|
||||
}
|
||||
|
||||
}
|
||||
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
|
||||
|
||||
}
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
|
||||
{
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
b3Vector3 position=b3MakeVector3((-ci.arraySizeX/2+i)*ci.gapX,50+j*ci.gapY,(-ci.arraySizeZ/2+k)*ci.gapZ);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConcaveSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
ConcaveScene::setupScene(ci);
|
||||
|
||||
float camPos[4]={0,50,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraPitch(45);
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(40);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ConcaveSphereScene::createDynamicObjects(const ConstructionInfo& ci)
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int index=0;
|
||||
int curColor = 0;
|
||||
float radius = 1;
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerSphereShape(radius);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int prevGraphicsShapeIndex = registerGraphicsSphereShape(ci,radius,false);
|
||||
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
float mass = 1.f;
|
||||
|
||||
|
||||
b3Vector3 position=b3MakeVector3(-(ci.arraySizeX/2)*8+i*8,50+j*8,-(ci.arraySizeZ/2)*8+k*8);
|
||||
|
||||
//b3Vector3 position(0,-41,0);//0,0,0);//i*radius*3,-41+j*radius*3,k*radius*3);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
101
examples/OpenCL/rigidbody/ConcaveScene.h
Normal file
101
examples/OpenCL/rigidbody/ConcaveScene.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef CONCAVE_SCENE_H
|
||||
#define CONCAVE_SCENE_H
|
||||
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
class ConcaveScene : public GpuRigidBodyDemo
|
||||
{
|
||||
public:
|
||||
|
||||
ConcaveScene(){}
|
||||
virtual ~ConcaveScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "BoxTrimesh";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new ConcaveScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void setupScene(const ConstructionInfo& ci);
|
||||
|
||||
virtual void createDynamicObjects(const ConstructionInfo& ci);
|
||||
|
||||
virtual void createConcaveMesh(const ConstructionInfo& ci, const char* fileName, const b3Vector3& shift, const b3Vector3& scaling);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ConcaveSphereScene : public ConcaveScene
|
||||
{
|
||||
public:
|
||||
|
||||
ConcaveSphereScene(){}
|
||||
virtual ~ConcaveSphereScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "SphereTrimesh";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new ConcaveSphereScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void setupScene(const ConstructionInfo& ci);
|
||||
|
||||
virtual void createDynamicObjects(const ConstructionInfo& ci);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ConcaveCompoundScene : public ConcaveScene
|
||||
{
|
||||
public:
|
||||
|
||||
ConcaveCompoundScene(){}
|
||||
virtual ~ConcaveCompoundScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "CompoundConcave";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new ConcaveCompoundScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void setupScene(const ConstructionInfo& ci);
|
||||
|
||||
virtual void createDynamicObjects(const ConstructionInfo& ci);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ConcaveCompound2Scene : public ConcaveCompoundScene
|
||||
{
|
||||
public:
|
||||
|
||||
ConcaveCompound2Scene(){}
|
||||
virtual ~ConcaveCompound2Scene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "GRBConcave2Compound";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new ConcaveCompound2Scene;
|
||||
return demo;
|
||||
}
|
||||
virtual void createDynamicObjects(const ConstructionInfo& ci);
|
||||
};
|
||||
|
||||
|
||||
#endif //CONCAVE_SCENE_H
|
||||
273
examples/OpenCL/rigidbody/GpuCompoundScene.cpp
Normal file
273
examples/OpenCL/rigidbody/GpuCompoundScene.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
#include "GpuCompoundScene.h"
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include "Bullet3Common/b3Transform.h"
|
||||
|
||||
#include "OpenGLWindow/GLInstanceGraphicsShape.h"
|
||||
|
||||
#define NUM_COMPOUND_CHILDREN_X 4
|
||||
#define NUM_COMPOUND_CHILDREN_Y 4
|
||||
#define NUM_COMPOUND_CHILDREN_Z 4
|
||||
|
||||
|
||||
|
||||
void GpuCompoundScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
createStaticEnvironment(ci);
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
float scaling[4] = {1,1,1,1};
|
||||
|
||||
GLInstanceVertex* cubeVerts = (GLInstanceVertex*)&cube_vertices[0];
|
||||
int stride2 = sizeof(GLInstanceVertex);
|
||||
b3Assert(stride2 == strideInBytes);
|
||||
int index=0;
|
||||
int colIndex = -1;
|
||||
b3AlignedObjectArray<GLInstanceVertex> vertexArray;
|
||||
b3AlignedObjectArray<int> indexArray;
|
||||
{
|
||||
int childColIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
|
||||
|
||||
/* b3Vector3 childPositions[3] = {
|
||||
b3Vector3(0,-2,0),
|
||||
b3Vector3(0,0,0),
|
||||
b3Vector3(0,0,2)
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
b3AlignedObjectArray<b3GpuChildShape> childShapes;
|
||||
|
||||
for (int x=0;x<NUM_COMPOUND_CHILDREN_X;x++)
|
||||
for (int y=0;y<NUM_COMPOUND_CHILDREN_Y;y++)
|
||||
for (int z=0;z<NUM_COMPOUND_CHILDREN_Z;z++)
|
||||
{
|
||||
int blax = x!=0 ?1 : 0;
|
||||
int blay = y!=0 ?1 : 0;
|
||||
int blaz = z!=0 ?1 : 0;
|
||||
int bla=blax+blay+blaz;
|
||||
if (bla!=1)
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
//for now, only support polyhedral child shapes
|
||||
b3GpuChildShape child;
|
||||
child.m_shapeIndex = childColIndex;
|
||||
b3Vector3 pos=b3MakeVector3((x-NUM_COMPOUND_CHILDREN_X/2.f)*2,(y-NUM_COMPOUND_CHILDREN_X/2.f)*2,(z-NUM_COMPOUND_CHILDREN_X/2.f)*2);//childPositions[i];
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
child.m_childPosition[v] = pos[v];
|
||||
child.m_childOrientation[v] = orn[v];
|
||||
}
|
||||
childShapes.push_back(child);
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(pos);
|
||||
tr.setRotation(orn);
|
||||
|
||||
int baseIndex = vertexArray.size();
|
||||
for (int j=0;j<numIndices;j++)
|
||||
indexArray.push_back(cube_indices[j]+baseIndex);
|
||||
|
||||
//add transformed graphics vertices and indices
|
||||
for (int v=0;v<numVertices;v++)
|
||||
{
|
||||
GLInstanceVertex vert = cubeVerts[v];
|
||||
b3Vector3 vertPos=b3MakeVector3(vert.xyzw[0],vert.xyzw[1],vert.xyzw[2]);
|
||||
b3Vector3 newPos = tr*vertPos;
|
||||
vert.xyzw[0] = newPos[0];
|
||||
vert.xyzw[1] = newPos[1];
|
||||
vert.xyzw[2] = newPos[2];
|
||||
vert.xyzw[3] = 0.f;
|
||||
vertexArray.push_back(vert);
|
||||
}
|
||||
|
||||
}
|
||||
colIndex= m_data->m_np->registerCompoundShape(&childShapes);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&vertexArray[0].xyzw[0],vertexArray.size(),&indexArray[0],indexArray.size());
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,0,1,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
float mass = 1;//j==0? 0.f : 1.f;
|
||||
|
||||
b3Vector3 position=b3MakeVector3((i-ci.arraySizeX/2.)*ci.gapX,35+j*3*ci.gapY,(k-ci.arraySizeZ/2.f)*ci.gapZ);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.7);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
|
||||
|
||||
float camPos[4]={0,0,0};//65.5,4.5,65.5,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(320);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GpuCompoundScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
|
||||
|
||||
|
||||
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
int colIndex = 0;
|
||||
|
||||
{
|
||||
if (1)
|
||||
{
|
||||
float radius = 41;
|
||||
int prevGraphicsShapeIndex = -1;
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (radius>=100)
|
||||
{
|
||||
int numVertices = sizeof(detailed_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(detailed_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&detailed_sphere_vertices[0],numVertices,detailed_sphere_indices,numIndices);
|
||||
} else
|
||||
{
|
||||
bool usePointSprites = false;
|
||||
if (usePointSprites)
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=10)
|
||||
{
|
||||
int numVertices = sizeof(medium_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(medium_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&medium_sphere_vertices[0],numVertices,medium_sphere_indices,numIndices);
|
||||
} else
|
||||
{
|
||||
int numVertices = sizeof(low_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(low_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&low_sphere_vertices[0],numVertices,low_sphere_indices,numIndices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 1;
|
||||
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerSphereShape(radius);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
float mass = 0.f;
|
||||
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position=b3MakeVector3(0,-41,0);
|
||||
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GpuCompoundPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
{
|
||||
|
||||
int index=0;
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
float constant=0.f;
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
|
||||
b3Vector4 scaling=b3MakeVector4(400,1.,400,1);
|
||||
|
||||
//int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
// b3Quaternion orn(b3Vector3(1,0,0),0.3);
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
}
|
||||
50
examples/OpenCL/rigidbody/GpuCompoundScene.h
Normal file
50
examples/OpenCL/rigidbody/GpuCompoundScene.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef GPU_COMPOUND_SCENE_H
|
||||
#define GPU_COMPOUND_SCENE_H
|
||||
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
|
||||
class GpuCompoundScene : public GpuRigidBodyDemo
|
||||
{
|
||||
public:
|
||||
|
||||
GpuCompoundScene(){}
|
||||
virtual ~GpuCompoundScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "CompoundOnSphere";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new GpuCompoundScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void setupScene(const ConstructionInfo& ci);
|
||||
|
||||
virtual void createStaticEnvironment(const ConstructionInfo& ci);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class GpuCompoundPlaneScene : public GpuCompoundScene
|
||||
{
|
||||
public:
|
||||
|
||||
GpuCompoundPlaneScene(){}
|
||||
virtual ~GpuCompoundPlaneScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "CompoundOnPlane";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new GpuCompoundPlaneScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void createStaticEnvironment(const ConstructionInfo& ci);
|
||||
|
||||
};
|
||||
#endif //GPU_COMPOUND_SCENE_H
|
||||
651
examples/OpenCL/rigidbody/GpuConvexScene.cpp
Normal file
651
examples/OpenCL/rigidbody/GpuConvexScene.cpp
Normal file
@@ -0,0 +1,651 @@
|
||||
#include "GpuConvexScene.h"
|
||||
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "../OpenGLWindow/ShapeData.h"
|
||||
|
||||
#include "../OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "../CommonInterfaces/CommonWindowInterface.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuSapBroadphase.h"
|
||||
#include "../CommonOpenCL/GpuDemoInternalData.h"
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "../OpenGLWindow/OpenGLInclude.h"
|
||||
#include "../OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
|
||||
#include "Bullet3Dynamics/ConstraintSolver/b3Point2PointConstraint.h"
|
||||
#include "../OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "Bullet3OpenCL/Raycast/b3GpuRaycast.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3ConvexUtility.h"
|
||||
#include "Bullet3Dynamics/ConstraintSolver/b3FixedConstraint.h"
|
||||
|
||||
#include "../OpenGLWindow/GLRenderToTexture.h"
|
||||
|
||||
static bool gUseInstancedCollisionShapes = true;
|
||||
extern int gGpuArraySizeX;
|
||||
extern int gGpuArraySizeY;
|
||||
extern int gGpuArraySizeZ;
|
||||
|
||||
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3RaycastInfo.h"
|
||||
|
||||
class GpuConvexScene : public GpuRigidBodyDemo
|
||||
{
|
||||
protected:
|
||||
|
||||
class b3GpuRaycast* m_raycaster;
|
||||
|
||||
public:
|
||||
|
||||
GpuConvexScene(GUIHelperInterface* helper)
|
||||
:GpuRigidBodyDemo(helper), m_raycaster(0)
|
||||
{
|
||||
}
|
||||
virtual ~GpuConvexScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "Tetrahedra";
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void setupScene();
|
||||
|
||||
virtual void destroyScene();
|
||||
|
||||
virtual int createDynamicsObjects();
|
||||
|
||||
virtual int createDynamicsObjects2(const float* vertices, int numVertices, const int* indices,int numIndices);
|
||||
|
||||
virtual void createStaticEnvironment();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class GpuConvexPlaneScene : public GpuConvexScene
|
||||
{
|
||||
public:
|
||||
|
||||
GpuConvexPlaneScene(GUIHelperInterface* helper)
|
||||
:GpuConvexScene(helper){}
|
||||
virtual ~GpuConvexPlaneScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "ConvexOnPlane";
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void createStaticEnvironment();
|
||||
|
||||
};
|
||||
|
||||
|
||||
class GpuBoxPlaneScene : public GpuConvexPlaneScene
|
||||
{
|
||||
public:
|
||||
|
||||
GpuBoxPlaneScene(GUIHelperInterface* helper):GpuConvexPlaneScene(helper){}
|
||||
virtual ~GpuBoxPlaneScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "BoxBox";
|
||||
}
|
||||
|
||||
|
||||
virtual int createDynamicsObjects();
|
||||
|
||||
|
||||
};
|
||||
|
||||
class GpuTetraScene : public GpuConvexScene
|
||||
{
|
||||
|
||||
protected:
|
||||
void createFromTetGenData(const char* ele, const char* node);
|
||||
|
||||
public:
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "TetraBreakable";
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual int createDynamicsObjects();
|
||||
|
||||
};
|
||||
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
void GpuConvexScene::setupScene()
|
||||
{
|
||||
|
||||
|
||||
m_raycaster = new b3GpuRaycast(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue);
|
||||
|
||||
int index=0;
|
||||
createStaticEnvironment();
|
||||
|
||||
index+=createDynamicsObjects();
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
|
||||
float camPos[4]={0,0,0,0};//ci.arraySizeX,ci.arraySizeY/2,ci.arraySizeZ,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraTargetPosition(camPos[0],camPos[1],camPos[2]);
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraDistance(150);
|
||||
//m_instancingRenderer->setCameraYaw(85);
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraYaw(30);
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->setCameraPitch(225);
|
||||
|
||||
|
||||
m_guiHelper->getRenderInterface()->updateCamera(1);//>updateCamera();
|
||||
|
||||
char msg[1024];
|
||||
int numInstances = index;
|
||||
sprintf(msg,"Num objects = %d",numInstances);
|
||||
b3Printf(msg);
|
||||
|
||||
//if (ci.m_gui)
|
||||
// ci.m_gui->setStatusBarMessage(msg,true);
|
||||
}
|
||||
|
||||
void GpuConvexScene::destroyScene()
|
||||
{
|
||||
delete m_raycaster;
|
||||
m_raycaster = 0;
|
||||
}
|
||||
|
||||
int GpuConvexScene::createDynamicsObjects()
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
/*int numVertices = sizeof(barrel_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(barrel_indices)/sizeof(int);
|
||||
return createDynamicsObjects2(ci,barrel_vertices,numVertices,barrel_indices,numIndices);
|
||||
*/
|
||||
|
||||
int numVertices = sizeof(tetra_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(tetra_indices)/sizeof(int);
|
||||
return createDynamicsObjects2(tetra_vertices,numVertices,tetra_indices,numIndices);
|
||||
|
||||
}
|
||||
|
||||
int GpuBoxPlaneScene::createDynamicsObjects()
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
return createDynamicsObjects2(cube_vertices_textured,numVertices,cube_indices,numIndices);
|
||||
}
|
||||
|
||||
|
||||
int GpuConvexScene::createDynamicsObjects2( const float* vertices, int numVertices, const int* indices, int numIndices)
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int textureIndex = -1;
|
||||
if (0)
|
||||
{
|
||||
int width,height,n;
|
||||
|
||||
const char* filename = "data/cube.png";
|
||||
const unsigned char* image=0;
|
||||
|
||||
const char* prefix[]={"./","../","../../","../../../","../../../../"};
|
||||
int numprefix = sizeof(prefix)/sizeof(const char*);
|
||||
|
||||
for (int i=0;!image && i<numprefix;i++)
|
||||
{
|
||||
char relativeFileName[1024];
|
||||
sprintf(relativeFileName,"%s%s",prefix[i],filename);
|
||||
image = loadImage(relativeFileName,width,height,n);
|
||||
}
|
||||
|
||||
b3Assert(image);
|
||||
if (image)
|
||||
{
|
||||
textureIndex = m_instancingRenderer->registerTexture(image,width,height);
|
||||
}
|
||||
}
|
||||
|
||||
int shapeId = m_guiHelper->getRenderInterface()->registerShape(&vertices[0],numVertices,indices,numIndices,B3_GL_TRIANGLES,textureIndex);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
|
||||
|
||||
int curColor = 0;
|
||||
float scaling[4] = {1,1,1,1};
|
||||
int prevBody = -1;
|
||||
int insta = 0;
|
||||
|
||||
b3ConvexUtility* utilPtr = new b3ConvexUtility();
|
||||
|
||||
{
|
||||
b3AlignedObjectArray<b3Vector3> verts;
|
||||
|
||||
unsigned char* vts = (unsigned char*) vertices;
|
||||
for (int i=0;i<numVertices;i++)
|
||||
{
|
||||
float* vertex = (float*) &vts[i*strideInBytes];
|
||||
verts.push_back(b3MakeVector3(vertex[0]*scaling[0],vertex[1]*scaling[1],vertex[2]*scaling[2]));
|
||||
}
|
||||
|
||||
bool merge = true;
|
||||
if (numVertices)
|
||||
{
|
||||
utilPtr->initializePolyhedralFeatures(&verts[0],verts.size(),merge);
|
||||
}
|
||||
}
|
||||
|
||||
int colIndex=-1;
|
||||
if (gUseInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
//int colIndex = m_data->m_np->registerSphereShape(1);
|
||||
for (int i=0;i<gGpuArraySizeX;i++)
|
||||
{
|
||||
|
||||
|
||||
//printf("%d of %d\n", i, ci.arraySizeX);
|
||||
for (int j=0;j<gGpuArraySizeY;j++)
|
||||
{
|
||||
|
||||
for (int k=0;k<gGpuArraySizeZ;k++)
|
||||
{
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&vertices[0],strideInBytes,numVertices, scaling);
|
||||
if (!gUseInstancedCollisionShapes)
|
||||
colIndex = m_data->m_np->registerConvexHullShape(utilPtr);
|
||||
|
||||
float mass = 1.f;
|
||||
if (j==0)//ci.arraySizeY-1)
|
||||
{
|
||||
//mass=0.f;
|
||||
}
|
||||
b3Vector3 position = b3MakeVector3(((j+1)&1)+i*2.2,1+j*2.,((j+1)&1)+k*2.2);
|
||||
//b3Vector3 position = b3MakeVector3(i*2,1+j*2,k*2);
|
||||
//b3Vector3 position=b3MakeVector3(1,0.9,1);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scalin=b3MakeVector4(1,1,1,1);
|
||||
int id = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
if (prevBody>=0)
|
||||
{
|
||||
//b3Point2PointConstraint* p2p = new b3Point2PointConstraint(pid,prevBody,b3Vector3(0,-1.1,0),b3Vector3(0,1.1,0));
|
||||
// m_data->m_rigidBodyPipeline->addConstraint(p2p);//,false);
|
||||
}
|
||||
prevBody = pid;
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete utilPtr;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
void GpuConvexScene::createStaticEnvironment()
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling=b3MakeVector4(400,400,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,-400,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GpuConvexPlaneScene::createStaticEnvironment()
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = m_guiHelper->getRenderInterface()->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling=b3MakeVector4(400,400,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,-400,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int id = m_guiHelper->getRenderInterface()->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void GpuConvexPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling=b3MakeVector4(100,0.001,100,1);
|
||||
|
||||
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 normal=b3MakeVector3(0,1,0);
|
||||
float constant=0.f;
|
||||
int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
|
||||
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
struct TetraBunny
|
||||
{
|
||||
#include "bunny.inl"
|
||||
};
|
||||
|
||||
struct TetraCube
|
||||
{
|
||||
#include "cube.inl"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static int nextLine(const char* buffer)
|
||||
{
|
||||
int numBytesRead=0;
|
||||
|
||||
while (*buffer != '\n')
|
||||
{
|
||||
buffer++;
|
||||
numBytesRead++;
|
||||
}
|
||||
|
||||
|
||||
if (buffer[0]==0x0a)
|
||||
{
|
||||
buffer++;
|
||||
numBytesRead++;
|
||||
}
|
||||
return numBytesRead;
|
||||
}
|
||||
|
||||
static float mytetra_vertices[] =
|
||||
{
|
||||
-1.f, 0, -1.f, 0.5f, 0, 1,0, 0,0,
|
||||
-1.f, 0, 1.f, 0.5f, 0, 1,0, 1,0,
|
||||
1.f, 0, 1.f, 0.5f, 0, 1,0, 1,1,
|
||||
1.f, 0, -1.f, 0.5f, 0, 1,0, 0,1
|
||||
};
|
||||
|
||||
static int mytetra_indices[]=
|
||||
{
|
||||
0,1,2,
|
||||
3,1,2,3,2,0,
|
||||
3,0,1
|
||||
};
|
||||
|
||||
|
||||
/* Create from TetGen .ele, .face, .node data */
|
||||
void GpuTetraScene::createFromTetGenData(const char* ele,
|
||||
const char* node)
|
||||
{
|
||||
b3Scalar scaling(10);
|
||||
|
||||
b3AlignedObjectArray<b3Vector3> pos;
|
||||
int nnode=0;
|
||||
int ndims=0;
|
||||
int nattrb=0;
|
||||
int hasbounds=0;
|
||||
int result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds);
|
||||
result = sscanf(node,"%d %d %d %d",&nnode,&ndims,&nattrb,&hasbounds);
|
||||
node += nextLine(node);
|
||||
|
||||
//b3AlignedObjectArray<b3Vector3> rigidBodyPositions;
|
||||
//b3AlignedObjectArray<int> rigidBodyIds;
|
||||
|
||||
pos.resize(nnode);
|
||||
for(int i=0;i<pos.size();++i)
|
||||
{
|
||||
int index=0;
|
||||
//int bound=0;
|
||||
float x,y,z;
|
||||
sscanf(node,"%d %f %f %f",&index,&x,&y,&z);
|
||||
|
||||
// sn>>index;
|
||||
// sn>>x;sn>>y;sn>>z;
|
||||
node += nextLine(node);
|
||||
|
||||
//for(int j=0;j<nattrb;++j)
|
||||
// sn>>a;
|
||||
|
||||
//if(hasbounds)
|
||||
// sn>>bound;
|
||||
|
||||
pos[index].setX(b3Scalar(x)*scaling);
|
||||
pos[index].setY(b3Scalar(y)*scaling);
|
||||
pos[index].setZ(b3Scalar(z)*scaling);
|
||||
}
|
||||
|
||||
|
||||
if(ele&&ele[0])
|
||||
{
|
||||
int ntetra=0;
|
||||
int ncorner=0;
|
||||
int neattrb=0;
|
||||
sscanf(ele,"%d %d %d",&ntetra,&ncorner,&neattrb);
|
||||
ele += nextLine(ele);
|
||||
|
||||
//se>>ntetra;se>>ncorner;se>>neattrb;
|
||||
for(int i=0;i<ntetra;++i)
|
||||
{
|
||||
int index=0;
|
||||
int ni[4];
|
||||
|
||||
//se>>index;
|
||||
//se>>ni[0];se>>ni[1];se>>ni[2];se>>ni[3];
|
||||
sscanf(ele,"%d %d %d %d %d",&index,&ni[0],&ni[1],&ni[2],&ni[3]);
|
||||
ele+=nextLine(ele);
|
||||
|
||||
b3Vector3 average=b3MakeVector3(0,0,0);
|
||||
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
average+=pos[ni[v]];
|
||||
}
|
||||
average/=4;
|
||||
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
b3Vector3 shiftedPos = pos[ni[v]]-average;
|
||||
mytetra_vertices[0+v*9] = shiftedPos.getX();
|
||||
mytetra_vertices[1+v*9] = shiftedPos.getY();
|
||||
mytetra_vertices[2+v*9] = shiftedPos.getZ();
|
||||
}
|
||||
//todo: subtract average
|
||||
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(mytetra_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(mytetra_indices)/sizeof(int);
|
||||
int shapeId = m_instancingRenderer->registerShape(&mytetra_vertices[0],numVertices,mytetra_indices,numIndices);
|
||||
int group=1;
|
||||
int mask=1;
|
||||
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling=b3MakeVector4(1,1,1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&mytetra_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position=b3MakeVector3(0,150,0);
|
||||
// position+=average;//*1.2;//*2;
|
||||
position+=average*1.2;//*2;
|
||||
//rigidBodyPositions.push_back(position);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
static int curColor=0;
|
||||
b3Vector4 color = colors[curColor++];
|
||||
curColor&=3;
|
||||
|
||||
int id = m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(1.f,position,orn,colIndex,0,false);
|
||||
//rigidBodyIds.push_back(pid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//for(int j=0;j<neattrb;++j)
|
||||
// se>>a;
|
||||
//psb->appendTetra(ni[0],ni[1],ni[2],ni[3]);
|
||||
|
||||
}
|
||||
// printf("Nodes: %u\r\n",psb->m_nodes.size());
|
||||
// printf("Links: %u\r\n",psb->m_links.size());
|
||||
// printf("Faces: %u\r\n",psb->m_faces.size());
|
||||
// printf("Tetras: %u\r\n",psb->m_tetras.size());
|
||||
|
||||
}
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
m_data->m_np->writeAllBodiesToGpu();
|
||||
m_data->m_bp->writeAabbsToGpu();
|
||||
m_data->m_rigidBodyPipeline->setupGpuAabbsFull();
|
||||
m_data->m_bp->calculateOverlappingPairs(m_data->m_config.m_maxBroadphasePairs);
|
||||
|
||||
int numPairs = m_data->m_bp->getNumOverlap();
|
||||
cl_mem pairs = m_data->m_bp->getOverlappingPairBuffer();
|
||||
b3OpenCLArray<b3Int2> clPairs(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
clPairs.setFromOpenCLBuffer(pairs,numPairs);
|
||||
b3AlignedObjectArray<b3Int2> allPairs;
|
||||
clPairs.copyToHost(allPairs);
|
||||
|
||||
for (int p=0;p<allPairs.size();p++)
|
||||
{
|
||||
b3Vector3 posA,posB;
|
||||
b3Quaternion ornA,ornB;
|
||||
int bodyIndexA = allPairs[p].x;
|
||||
int bodyIndexB = allPairs[p].y;
|
||||
|
||||
m_data->m_np->getObjectTransformFromCpu(posA,ornA,bodyIndexA);
|
||||
m_data->m_np->getObjectTransformFromCpu(posB,ornB,bodyIndexB);
|
||||
|
||||
b3Vector3 pivotWorld = (posA+posB)*0.5f;
|
||||
b3Transform transA,transB;
|
||||
transA.setIdentity();
|
||||
transA.setOrigin(posA);
|
||||
transA.setRotation(ornA);
|
||||
transB.setIdentity();
|
||||
transB.setOrigin(posB);
|
||||
transB.setRotation(ornB);
|
||||
b3Vector3 pivotInA = transA.inverse()*pivotWorld;
|
||||
b3Vector3 pivotInB = transB.inverse()*pivotWorld;
|
||||
|
||||
b3Transform frameInA,frameInB;
|
||||
frameInA.setIdentity();
|
||||
frameInB.setIdentity();
|
||||
frameInA.setOrigin(pivotInA);
|
||||
frameInB.setOrigin(pivotInB);
|
||||
b3Quaternion relTargetAB = frameInA.getRotation()*frameInB.getRotation().inverse();
|
||||
|
||||
//c = new b3FixedConstraint(pid,prevBody,frameInA,frameInB);
|
||||
float breakingThreshold = 45;//37.f;
|
||||
//c->setBreakingImpulseThreshold(37.1);
|
||||
bool useGPU = true;
|
||||
if (useGPU)
|
||||
{
|
||||
int cid = m_data->m_rigidBodyPipeline->createFixedConstraint(bodyIndexA,bodyIndexB,pivotInA,pivotInB,relTargetAB,breakingThreshold);
|
||||
} else
|
||||
{
|
||||
b3FixedConstraint* c = new b3FixedConstraint(bodyIndexA,bodyIndexB,frameInA,frameInB);
|
||||
c->setBreakingImpulseThreshold(breakingThreshold);
|
||||
m_data->m_rigidBodyPipeline->addConstraint(c);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
printf("numPairs = %d\n",numPairs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int GpuTetraScene::createDynamicsObjects()
|
||||
{
|
||||
|
||||
//createFromTetGenData(TetraCube::getElements(),TetraCube::getNodes());
|
||||
createFromTetGenData(TetraBunny::getElements(),TetraBunny::getNodes());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
class CommonExampleInterface* OpenCLBoxBoxCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new GpuBoxPlaneScene(options.m_guiHelper);
|
||||
}
|
||||
7
examples/OpenCL/rigidbody/GpuConvexScene.h
Normal file
7
examples/OpenCL/rigidbody/GpuConvexScene.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef GPU_CONVEX_SCENE_H
|
||||
#define GPU_CONVEX_SCENE_H
|
||||
|
||||
class CommonExampleInterface* OpenCLBoxBoxCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //GPU_CONVEX_SCENE_H
|
||||
512
examples/OpenCL/rigidbody/GpuRigidBodyDemo.cpp
Normal file
512
examples/OpenCL/rigidbody/GpuRigidBodyDemo.cpp
Normal file
@@ -0,0 +1,512 @@
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "../OpenGLWindow/ShapeData.h"
|
||||
#include "../OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "../CommonInterfaces/CommonWindowInterface.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuSapBroadphase.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuGridBroadphase.h"
|
||||
|
||||
#include "../CommonOpenCL/GpuDemoInternalData.h"
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "../OpenGLWindow/OpenGLInclude.h"
|
||||
#include "../OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhaseInternalData.h"
|
||||
#include "stb_image/stb_image.h"
|
||||
#include "../OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
|
||||
extern int gPreferredOpenCLDeviceIndex;
|
||||
extern int gPreferredOpenCLPlatformIndex;
|
||||
extern int gGpuArraySizeX;
|
||||
extern int gGpuArraySizeY;
|
||||
extern int gGpuArraySizeZ;
|
||||
|
||||
static b3KeyboardCallback oldCallback = 0;
|
||||
extern bool gReset;
|
||||
bool useUniformGrid = false;
|
||||
bool convertOnCpu = false;
|
||||
|
||||
#define MSTRINGIFY(A) #A
|
||||
|
||||
static const char* s_rigidBodyKernelString = MSTRINGIFY(
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float4 m_pos;
|
||||
float4 m_quat;
|
||||
float4 m_linVel;
|
||||
float4 m_angVel;
|
||||
unsigned int m_collidableIdx;
|
||||
float m_invMass;
|
||||
float m_restituitionCoeff;
|
||||
float m_frictionCoeff;
|
||||
} Body;
|
||||
|
||||
__kernel void
|
||||
copyTransformsToVBOKernel( __global Body* gBodies, __global float4* posOrnColor, const int numNodes)
|
||||
{
|
||||
int nodeID = get_global_id(0);
|
||||
if( nodeID < numNodes )
|
||||
{
|
||||
posOrnColor[nodeID] = (float4) (gBodies[nodeID].m_pos.xyz,1.0);
|
||||
posOrnColor[nodeID + numNodes] = gBodies[nodeID].m_quat;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GpuRigidBodyDemo::GpuRigidBodyDemo(GUIHelperInterface* helper)
|
||||
:CommonOpenCLBase(helper),
|
||||
m_instancingRenderer(0),
|
||||
m_window(0)
|
||||
{
|
||||
if (helper->getRenderInterface()->getInternalData())
|
||||
{
|
||||
m_instancingRenderer = (GLInstancingRenderer*)helper->getRenderInterface();
|
||||
} else
|
||||
{
|
||||
m_instancingRenderer = 0;
|
||||
}
|
||||
|
||||
m_window = helper->getAppInterface()->m_window;
|
||||
|
||||
m_data = new GpuRigidBodyDemoInternalData;
|
||||
}
|
||||
GpuRigidBodyDemo::~GpuRigidBodyDemo()
|
||||
{
|
||||
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void PairKeyboardCallback(int key, int state)
|
||||
{
|
||||
if (key=='R' && state)
|
||||
{
|
||||
gReset = true;
|
||||
}
|
||||
|
||||
//b3DefaultKeyboardCallback(key,state);
|
||||
oldCallback(key,state);
|
||||
}
|
||||
|
||||
void GpuRigidBodyDemo::setupScene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GpuRigidBodyDemo::initPhysics()
|
||||
{
|
||||
|
||||
initCL(gPreferredOpenCLDeviceIndex,gPreferredOpenCLPlatformIndex);
|
||||
|
||||
m_guiHelper->setUpAxis(1);
|
||||
|
||||
if (m_clData->m_clContext)
|
||||
{
|
||||
int errNum=0;
|
||||
|
||||
cl_program rbProg=0;
|
||||
m_data->m_copyTransformsToVBOKernel = b3OpenCLUtils::compileCLKernelFromString(m_clData->m_clContext,m_clData->m_clDevice,s_rigidBodyKernelString,"copyTransformsToVBOKernel",&errNum,rbProg);
|
||||
|
||||
m_data->m_config.m_maxConvexBodies = b3Max(m_data->m_config.m_maxConvexBodies,gGpuArraySizeX*gGpuArraySizeY*gGpuArraySizeZ+10);
|
||||
m_data->m_config.m_maxConvexShapes = m_data->m_config.m_maxConvexBodies;
|
||||
int maxPairsPerBody = 16;
|
||||
m_data->m_config.m_maxBroadphasePairs = maxPairsPerBody*m_data->m_config.m_maxConvexBodies;
|
||||
m_data->m_config.m_maxContactCapacity = m_data->m_config.m_maxBroadphasePairs;
|
||||
|
||||
|
||||
b3GpuNarrowPhase* np = new b3GpuNarrowPhase(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue,m_data->m_config);
|
||||
b3GpuBroadphaseInterface* bp =0;
|
||||
|
||||
if (useUniformGrid)
|
||||
{
|
||||
bp = new b3GpuGridBroadphase(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue);
|
||||
} else
|
||||
{
|
||||
bp = new b3GpuSapBroadphase(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue);
|
||||
}
|
||||
m_data->m_np = np;
|
||||
m_data->m_bp = bp;
|
||||
m_data->m_broadphaseDbvt = new b3DynamicBvhBroadphase(m_data->m_config.m_maxConvexBodies);
|
||||
|
||||
m_data->m_rigidBodyPipeline = new b3GpuRigidBodyPipeline(m_clData->m_clContext,m_clData->m_clDevice,m_clData->m_clQueue, np, bp,m_data->m_broadphaseDbvt,m_data->m_config);
|
||||
|
||||
|
||||
setupScene();
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
np->writeAllBodiesToGpu();
|
||||
bp->writeAabbsToGpu();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_guiHelper->getRenderInterface()->writeTransforms();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GpuRigidBodyDemo::exitPhysics()
|
||||
{
|
||||
destroyScene();
|
||||
|
||||
delete m_data->m_instancePosOrnColor;
|
||||
delete m_data->m_rigidBodyPipeline;
|
||||
delete m_data->m_broadphaseDbvt;
|
||||
|
||||
|
||||
|
||||
delete m_data->m_np;
|
||||
m_data->m_np = 0;
|
||||
delete m_data->m_bp;
|
||||
m_data->m_bp = 0;
|
||||
|
||||
exitCL();
|
||||
}
|
||||
|
||||
|
||||
void GpuRigidBodyDemo::renderScene()
|
||||
{
|
||||
m_guiHelper->getRenderInterface()->renderScene();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GpuRigidBodyDemo::stepSimulation(float deltaTime)
|
||||
{
|
||||
if (!m_instancingRenderer)
|
||||
return;
|
||||
|
||||
bool animate=true;
|
||||
int numObjects= m_data->m_rigidBodyPipeline->getNumBodies();
|
||||
//printf("numObjects=%d\n",numObjects);
|
||||
if (numObjects > m_instancingRenderer->getInstanceCapacity())
|
||||
{
|
||||
static bool once = true;
|
||||
if (once)
|
||||
{
|
||||
once=false;
|
||||
b3Assert(0);
|
||||
b3Error("m_instancingRenderer out-of-memory\n");
|
||||
}
|
||||
numObjects = m_instancingRenderer->getInstanceCapacity();
|
||||
}
|
||||
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
|
||||
b3Vector4* positions = 0;
|
||||
if (animate && numObjects)
|
||||
{
|
||||
B3_PROFILE("gl2cl");
|
||||
|
||||
if (!m_data->m_instancePosOrnColor)
|
||||
{
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(b3Vector4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
cl_bool blocking= CL_TRUE;
|
||||
positions= (b3Vector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_READ_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
m_data->m_instancePosOrnColor = new b3OpenCLArray<b3Vector4>(m_clData->m_clContext,m_clData->m_clQueue);
|
||||
m_data->m_instancePosOrnColor->resize(3*numObjects);
|
||||
m_data->m_instancePosOrnColor->copyFromHostPointer(positions,3*numObjects,0);
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
B3_PROFILE("stepSimulation");
|
||||
m_data->m_rigidBodyPipeline->stepSimulation(1./60.f);
|
||||
|
||||
}
|
||||
|
||||
if (numObjects)
|
||||
{
|
||||
if (convertOnCpu)
|
||||
{
|
||||
b3GpuNarrowPhaseInternalData* npData = m_data->m_np->getInternalData();
|
||||
npData->m_bodyBufferGPU->copyToHost(*npData->m_bodyBufferCPU);
|
||||
|
||||
b3AlignedObjectArray<b3Vector4> vboCPU;
|
||||
m_data->m_instancePosOrnColor->copyToHost(vboCPU);
|
||||
|
||||
for (int i=0;i<numObjects;i++)
|
||||
{
|
||||
b3Vector4 pos = (const b3Vector4&)npData->m_bodyBufferCPU->at(i).m_pos;
|
||||
b3Quat orn = npData->m_bodyBufferCPU->at(i).m_quat;
|
||||
pos.w = 1.f;
|
||||
vboCPU[i] = pos;
|
||||
vboCPU[i + numObjects] = (b3Vector4&)orn;
|
||||
}
|
||||
m_data->m_instancePosOrnColor->copyFromHost(vboCPU);
|
||||
|
||||
} else
|
||||
{
|
||||
B3_PROFILE("cl2gl_convert");
|
||||
int ciErrNum = 0;
|
||||
cl_mem bodies = m_data->m_rigidBodyPipeline->getBodyBuffer();
|
||||
b3LauncherCL launch(m_clData->m_clQueue,m_data->m_copyTransformsToVBOKernel,"m_copyTransformsToVBOKernel");
|
||||
launch.setBuffer(bodies);
|
||||
launch.setBuffer(m_data->m_instancePosOrnColor->getBufferCL());
|
||||
launch.setConst(numObjects);
|
||||
launch.launch1D(numObjects);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
if (animate && numObjects)
|
||||
{
|
||||
B3_PROFILE("cl2gl_upload");
|
||||
GLint err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
GLuint vbo = m_instancingRenderer->getInternalData()->m_vbo;
|
||||
|
||||
int arraySizeInBytes = numObjects * (3)*sizeof(b3Vector4);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
cl_bool blocking= CL_TRUE;
|
||||
positions= (b3Vector4*)glMapBufferRange( GL_ARRAY_BUFFER,m_instancingRenderer->getMaxShapeCapacity(),arraySizeInBytes, GL_MAP_WRITE_BIT );//GL_READ_WRITE);//GL_WRITE_ONLY
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
m_data->m_instancePosOrnColor->copyToHostPointer(positions,3*numObjects,0);
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER);
|
||||
err = glGetError();
|
||||
assert(err==GL_NO_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
b3Vector3 GpuRigidBodyDemo::getRayTo(int x,int y)
|
||||
{
|
||||
if (!m_instancingRenderer)
|
||||
return b3MakeVector3(0,0,0);
|
||||
|
||||
float top = 1.f;
|
||||
float bottom = -1.f;
|
||||
float nearPlane = 1.f;
|
||||
float tanFov = (top-bottom)*0.5f / nearPlane;
|
||||
float fov = b3Scalar(2.0) * b3Atan(tanFov);
|
||||
|
||||
b3Vector3 camPos,camTarget;
|
||||
m_instancingRenderer->getActiveCamera()->getCameraPosition(camPos);
|
||||
m_instancingRenderer->getActiveCamera()->getCameraTargetPosition(camTarget);
|
||||
|
||||
b3Vector3 rayFrom = camPos;
|
||||
b3Vector3 rayForward = (camTarget-camPos);
|
||||
rayForward.normalize();
|
||||
float farPlane = 10000.f;
|
||||
rayForward*= farPlane;
|
||||
|
||||
b3Vector3 rightOffset;
|
||||
b3Vector3 m_cameraUp=b3MakeVector3(0,1,0);
|
||||
b3Vector3 vertical = m_cameraUp;
|
||||
|
||||
b3Vector3 hor;
|
||||
hor = rayForward.cross(vertical);
|
||||
hor.normalize();
|
||||
vertical = hor.cross(rayForward);
|
||||
vertical.normalize();
|
||||
|
||||
float tanfov = tanf(0.5f*fov);
|
||||
|
||||
|
||||
hor *= 2.f * farPlane * tanfov;
|
||||
vertical *= 2.f * farPlane * tanfov;
|
||||
|
||||
b3Scalar aspect;
|
||||
float width = m_instancingRenderer->getScreenWidth();
|
||||
float height = m_instancingRenderer->getScreenHeight();
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
hor*=aspect;
|
||||
|
||||
|
||||
b3Vector3 rayToCenter = rayFrom + rayForward;
|
||||
b3Vector3 dHor = hor * 1.f/width;
|
||||
b3Vector3 dVert = vertical * 1.f/height;
|
||||
|
||||
|
||||
b3Vector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical;
|
||||
rayTo += b3Scalar(x) * dHor;
|
||||
rayTo -= b3Scalar(y) * dVert;
|
||||
return rayTo;
|
||||
}
|
||||
|
||||
unsigned char* GpuRigidBodyDemo::loadImage(const char* fileName, int& width, int& height, int& n)
|
||||
{
|
||||
unsigned char *data = stbi_load(fileName, &width, &height, &n, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
bool GpuRigidBodyDemo::keyboardCallback(int key, int state)
|
||||
{
|
||||
|
||||
if (m_data)
|
||||
{
|
||||
if (key==B3G_ALT )
|
||||
{
|
||||
m_data->m_altPressed = state;
|
||||
}
|
||||
if (key==B3G_CONTROL )
|
||||
{
|
||||
m_data->m_controlPressed = state;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GpuRigidBodyDemo::mouseMoveCallback(float x,float y)
|
||||
{
|
||||
if (!m_instancingRenderer)
|
||||
return false;
|
||||
|
||||
if (m_data->m_altPressed!=0 || m_data->m_controlPressed!=0)
|
||||
return false;
|
||||
|
||||
if (m_data->m_pickBody>=0 && m_data->m_pickConstraint>=0)
|
||||
{
|
||||
m_data->m_rigidBodyPipeline->removeConstraintByUid(m_data->m_pickConstraint);
|
||||
b3Vector3 newRayTo = getRayTo(x,y);
|
||||
b3Vector3 rayFrom;
|
||||
b3Vector3 oldPivotInB = m_data->m_pickPivotInB;
|
||||
b3Vector3 newPivotB;
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->getCameraPosition(rayFrom);
|
||||
b3Vector3 dir = newRayTo-rayFrom;
|
||||
dir.normalize();
|
||||
dir *= m_data->m_pickDistance;
|
||||
newPivotB = rayFrom + dir;
|
||||
m_data->m_pickPivotInB = newPivotB;
|
||||
m_data->m_rigidBodyPipeline->copyConstraintsToHost();
|
||||
m_data->m_pickConstraint = m_data->m_rigidBodyPipeline->createPoint2PointConstraint(m_data->m_pickBody,m_data->m_pickFixedBody,m_data->m_pickPivotInA,m_data->m_pickPivotInB,1e30);
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool GpuRigidBodyDemo::mouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
if (!m_instancingRenderer)
|
||||
return false;
|
||||
|
||||
if (state==1)
|
||||
{
|
||||
if(button==0 && (m_data->m_altPressed==0 && m_data->m_controlPressed==0))
|
||||
{
|
||||
b3AlignedObjectArray<b3RayInfo> rays;
|
||||
b3AlignedObjectArray<b3RayHit> hitResults;
|
||||
b3Vector3 camPos;
|
||||
m_guiHelper->getRenderInterface()->getActiveCamera()->getCameraPosition(camPos);
|
||||
|
||||
b3RayInfo ray;
|
||||
ray.m_from = camPos;
|
||||
ray.m_to = getRayTo(x,y);
|
||||
rays.push_back(ray);
|
||||
b3RayHit hit;
|
||||
hit.m_hitFraction = 1.f;
|
||||
hitResults.push_back(hit);
|
||||
m_data->m_rigidBodyPipeline->castRays(rays,hitResults);
|
||||
if (hitResults[0].m_hitFraction<1.f)
|
||||
{
|
||||
|
||||
int hitBodyA = hitResults[0].m_hitBody;
|
||||
if (m_data->m_np->getBodiesCpu()[hitBodyA].m_invMass)
|
||||
{
|
||||
//printf("hit!\n");
|
||||
m_data->m_np->readbackAllBodiesToCpu();
|
||||
m_data->m_pickBody = hitBodyA;
|
||||
|
||||
|
||||
|
||||
|
||||
//pivotInA
|
||||
b3Vector3 pivotInB;
|
||||
pivotInB.setInterpolate3(ray.m_from,ray.m_to,hitResults[0].m_hitFraction);
|
||||
b3Vector3 posA;
|
||||
b3Quaternion ornA;
|
||||
m_data->m_np->getObjectTransformFromCpu(posA,ornA,hitBodyA);
|
||||
b3Transform tr;
|
||||
tr.setOrigin(posA);
|
||||
tr.setRotation(ornA);
|
||||
b3Vector3 pivotInA = tr.inverse()*pivotInB;
|
||||
if (m_data->m_pickFixedBody<0)
|
||||
{
|
||||
b3Vector3 pos=b3MakeVector3(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
int fixedSphere = m_data->m_np->registerConvexHullShape(0,0,0,0);//>registerSphereShape(0.1);
|
||||
m_data->m_pickFixedBody = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0,pos,orn,fixedSphere,0,false);
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
m_data->m_bp->writeAabbsToGpu();
|
||||
|
||||
if (m_data->m_pickGraphicsShapeIndex<0)
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
m_data->m_pickGraphicsShapeIndex = m_guiHelper->getRenderInterface()->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
|
||||
float color[4] ={1,0,0,1};
|
||||
float scaling[4]={1,1,1,1};
|
||||
|
||||
m_data->m_pickGraphicsShapeInstance = m_guiHelper->getRenderInterface()->registerGraphicsInstance(m_data->m_pickGraphicsShapeIndex,pivotInB,orn,color,scaling);
|
||||
m_guiHelper->getRenderInterface()->writeTransforms();
|
||||
delete m_data->m_instancePosOrnColor;
|
||||
m_data->m_instancePosOrnColor=0;
|
||||
} else
|
||||
{
|
||||
m_guiHelper->getRenderInterface()->writeSingleInstanceTransformToCPU(pivotInB,orn,m_data->m_pickGraphicsShapeInstance);
|
||||
if (this->m_instancingRenderer)
|
||||
m_instancingRenderer->writeSingleInstanceTransformToGPU(pivotInB,orn,m_data->m_pickGraphicsShapeInstance);
|
||||
m_data->m_np->setObjectTransformCpu(pos,orn,m_data->m_pickFixedBody);
|
||||
}
|
||||
|
||||
}
|
||||
pivotInB.w = 0.f;
|
||||
m_data->m_pickPivotInA = pivotInA;
|
||||
m_data->m_pickPivotInB = pivotInB;
|
||||
m_data->m_rigidBodyPipeline->copyConstraintsToHost();
|
||||
m_data->m_pickConstraint = m_data->m_rigidBodyPipeline->createPoint2PointConstraint(hitBodyA,m_data->m_pickFixedBody,pivotInA,pivotInB,1e30);//hitResults[0].m_hitResult0
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
m_data->m_np->writeAllBodiesToGpu();
|
||||
m_data->m_pickDistance = (pivotInB-camPos).length();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (button==0)
|
||||
{
|
||||
if (m_data->m_pickConstraint>=0)
|
||||
{
|
||||
m_data->m_rigidBodyPipeline->removeConstraintByUid(m_data->m_pickConstraint);
|
||||
m_data->m_pickConstraint=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("button=%d, state=%d\n",button,state);
|
||||
return false;
|
||||
}
|
||||
47
examples/OpenCL/rigidbody/GpuRigidBodyDemo.h
Normal file
47
examples/OpenCL/rigidbody/GpuRigidBodyDemo.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef GPU_RIGID_BODY_DEMO_H
|
||||
#define GPU_RIGID_BODY_DEMO_H
|
||||
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "../CommonOpenCL/CommonOpenCLBase.h"
|
||||
|
||||
|
||||
class GpuRigidBodyDemo : public CommonOpenCLBase
|
||||
{
|
||||
protected:
|
||||
class GLInstancingRenderer* m_instancingRenderer;
|
||||
class GLPrimitiveRenderer* m_primRenderer;
|
||||
class CommonWindowInterface* m_window;
|
||||
|
||||
struct GpuRigidBodyDemoInternalData* m_data;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
GpuRigidBodyDemo(GUIHelperInterface* helper);
|
||||
virtual ~GpuRigidBodyDemo();
|
||||
|
||||
virtual void initPhysics();
|
||||
|
||||
virtual void setupScene();
|
||||
|
||||
virtual void destroyScene(){};
|
||||
|
||||
virtual void exitPhysics();
|
||||
|
||||
virtual void renderScene();
|
||||
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
//for picking
|
||||
b3Vector3 getRayTo(int x,int y);
|
||||
virtual bool mouseMoveCallback(float x,float y);
|
||||
virtual bool mouseButtonCallback(int button, int state, float x, float y);
|
||||
virtual bool keyboardCallback(int key, int state);
|
||||
|
||||
unsigned char* loadImage(const char* fileName, int& width, int& height, int& n);
|
||||
};
|
||||
|
||||
#endif //GPU_RIGID_BODY_DEMO_H
|
||||
|
||||
55
examples/OpenCL/rigidbody/GpuRigidBodyDemoInternalData.h
Normal file
55
examples/OpenCL/rigidbody/GpuRigidBodyDemoInternalData.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef GPU_RIGIDBODY_INTERNAL_DATA_H
|
||||
#define GPU_RIGIDBODY_INTERNAL_DATA_H
|
||||
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
|
||||
struct GpuRigidBodyDemoInternalData
|
||||
{
|
||||
|
||||
cl_kernel m_copyTransformsToVBOKernel;
|
||||
|
||||
b3OpenCLArray<b3Vector4>* m_instancePosOrnColor;
|
||||
|
||||
class b3GpuRigidBodyPipeline* m_rigidBodyPipeline;
|
||||
|
||||
class b3GpuNarrowPhase* m_np;
|
||||
class b3GpuBroadphaseInterface* m_bp;
|
||||
class b3DynamicBvhBroadphase* m_broadphaseDbvt;
|
||||
|
||||
b3Vector3 m_pickPivotInA;
|
||||
b3Vector3 m_pickPivotInB;
|
||||
float m_pickDistance;
|
||||
int m_pickBody;
|
||||
int m_pickConstraint;
|
||||
|
||||
int m_altPressed;
|
||||
int m_controlPressed;
|
||||
|
||||
int m_pickFixedBody;
|
||||
int m_pickGraphicsShapeIndex;
|
||||
int m_pickGraphicsShapeInstance;
|
||||
b3Config m_config;
|
||||
|
||||
GpuRigidBodyDemoInternalData()
|
||||
:m_instancePosOrnColor(0),
|
||||
m_copyTransformsToVBOKernel(0), m_rigidBodyPipeline(0),
|
||||
m_np(0),
|
||||
m_bp(0),
|
||||
m_broadphaseDbvt(0),
|
||||
m_pickConstraint(-1),
|
||||
m_pickFixedBody(-1),
|
||||
m_pickGraphicsShapeIndex(-1),
|
||||
m_pickGraphicsShapeInstance(-1),
|
||||
m_pickBody(-1),
|
||||
m_altPressed(0),
|
||||
m_controlPressed(0)
|
||||
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif//GPU_RIGIDBODY_INTERNAL_DATA_H
|
||||
|
||||
204
examples/OpenCL/rigidbody/GpuSphereScene.cpp
Normal file
204
examples/OpenCL/rigidbody/GpuSphereScene.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
#include "GpuSphereScene.h"
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
#include "Bullet3OpenCL/BroadphaseCollision/b3GpuSapBroadphase.h"
|
||||
#include "../GpuDemoInternalData.h"
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
#include "OpenGLWindow/GLInstanceRendererInternalData.h"
|
||||
#include "Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuRigidBodyPipeline.h"
|
||||
#include "Bullet3OpenCL/RigidBody/b3GpuNarrowPhase.h"
|
||||
#include "Bullet3Collision/NarrowPhaseCollision/b3Config.h"
|
||||
#include "GpuRigidBodyDemoInternalData.h"
|
||||
#include "Bullet3AppSupport/gwenUserInterface.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void GpuSphereScene::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
int strideInBytes = 9*sizeof(float);
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
//int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
bool writeInstanceToGpu = false;
|
||||
|
||||
if (0)
|
||||
{
|
||||
float radius = 60;
|
||||
int prevGraphicsShapeIndex = -1;
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (1)//radius>=100)
|
||||
{
|
||||
int numVertices = sizeof(detailed_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(detailed_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&detailed_sphere_vertices[0],numVertices,detailed_sphere_indices,numIndices);
|
||||
} else
|
||||
{
|
||||
bool usePointSprites = false;
|
||||
if (usePointSprites)
|
||||
{
|
||||
int numVertices = sizeof(point_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(point_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&point_sphere_vertices[0],numVertices,point_sphere_indices,numIndices,B3_GL_POINTS);
|
||||
} else
|
||||
{
|
||||
if (radius>=10)
|
||||
{
|
||||
int numVertices = sizeof(medium_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(medium_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&medium_sphere_vertices[0],numVertices,medium_sphere_indices,numIndices);
|
||||
} else
|
||||
{
|
||||
int numVertices = sizeof(low_sphere_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(low_sphere_indices)/sizeof(int);
|
||||
prevGraphicsShapeIndex = ci.m_instancingRenderer->registerShape(&low_sphere_vertices[0],numVertices,low_sphere_indices,numIndices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
int curColor = 0;
|
||||
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerSphereShape(radius);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
float mass = 0.f;
|
||||
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index, writeInstanceToGpu);
|
||||
|
||||
index++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3MakeVector4(1,0,0,1),
|
||||
b3MakeVector4(0,1,0,1),
|
||||
b3MakeVector4(0,1,1,1),
|
||||
b3MakeVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int curColor = 0;
|
||||
float radius = 61;
|
||||
//int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int colIndex = m_data->m_np->registerSphereShape(radius);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
int prevGraphicsShapeIndex = registerGraphicsSphereShape(ci,radius,false);
|
||||
|
||||
//for (int i=0;i<ci.arraySizeX;i++)
|
||||
{
|
||||
// for (int j=0;j<ci.arraySizeY;j++)
|
||||
{
|
||||
// for (int k=0;k<ci.arraySizeZ;k++)
|
||||
{
|
||||
int i=0,j=0,k=0;
|
||||
float mass = 0.f;
|
||||
|
||||
b3Vector3 position=b3MakeVector3(0,0,0);
|
||||
//b3Vector3 position((j&1)+i*142.2,-51+j*142.,(j&1)+k*142.2);
|
||||
//b3Vector3 position(0,-41,0);//0,0,0);//i*radius*3,-41+j*radius*3,k*radius*3);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling=b3MakeVector4(radius,radius,radius,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(prevGraphicsShapeIndex,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index, writeInstanceToGpu);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (1)
|
||||
{
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
b3Vector4 scaling=b3MakeVector4(0.5,0.5,0.5,1);//1,1,1,1);//0.1,0.1,0.1,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 normal=b3MakeVector3(0,-1,0);
|
||||
float constant=2;
|
||||
|
||||
|
||||
for (int j=-10;j<10;j++)
|
||||
for (int i=-10;i<10;i++)
|
||||
for (int k=0;k<30;k++)
|
||||
//int i=0;int j=0;
|
||||
{
|
||||
//int colIndex = m_data->m_np->registerPlaneShape(normal,constant);//>registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector4 position=b3MakeVector4(2*i,70+k*2,2*j+8,0);
|
||||
//b3Quaternion orn(0,0,0,1);
|
||||
b3Quaternion orn(b3MakeVector3(1,0,0),0.3);
|
||||
|
||||
b3Vector4 color=b3MakeVector4(0,0,1,1);
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(1.f,position,orn,colIndex,index,false);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!writeInstanceToGpu)
|
||||
{
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
}
|
||||
|
||||
float camPos[4]={ci.arraySizeX,ci.arraySizeY/2,ci.arraySizeZ,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(130);
|
||||
|
||||
|
||||
char msg[1024];
|
||||
int numInstances = index;
|
||||
sprintf(msg,"Num objects = %d",numInstances);
|
||||
ci.m_gui->setStatusBarMessage(msg,true);
|
||||
}
|
||||
27
examples/OpenCL/rigidbody/GpuSphereScene.h
Normal file
27
examples/OpenCL/rigidbody/GpuSphereScene.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef GPU_SPHERE_SCENE_H
|
||||
#define GPU_SPHERE_SCENE_H
|
||||
|
||||
#include "GpuRigidBodyDemo.h"
|
||||
|
||||
class GpuSphereScene : public GpuRigidBodyDemo
|
||||
{
|
||||
public:
|
||||
|
||||
GpuSphereScene(){}
|
||||
virtual ~GpuSphereScene(){}
|
||||
virtual const char* getName()
|
||||
{
|
||||
return "BoxOnSphere";
|
||||
}
|
||||
|
||||
static GpuDemo* MyCreateFunc()
|
||||
{
|
||||
GpuDemo* demo = new GpuSphereScene;
|
||||
return demo;
|
||||
}
|
||||
|
||||
virtual void setupScene(const ConstructionInfo& ci);
|
||||
|
||||
};
|
||||
|
||||
#endif //GPU_SPHERE_SCENE_H
|
||||
4
examples/OpenCL/rigidbody/bunny.inl
Normal file
4
examples/OpenCL/rigidbody/bunny.inl
Normal file
File diff suppressed because one or more lines are too long
4
examples/OpenCL/rigidbody/cube.inl
Normal file
4
examples/OpenCL/rigidbody/cube.inl
Normal file
File diff suppressed because one or more lines are too long
@@ -15,6 +15,9 @@ struct GLInstanceRendererInternalData
|
||||
int m_vboSize;
|
||||
GLuint m_vbo;
|
||||
int m_totalNumInstances;
|
||||
int m_maxNumObjectCapacity;
|
||||
int m_maxShapeCapacityInBytes;
|
||||
|
||||
};
|
||||
|
||||
#endif //GL_INSTANCE_RENDERER_INTERNAL_DATA_H
|
||||
|
||||
@@ -152,6 +152,7 @@ struct InternalDataRenderer : public GLInstanceRendererInternalData
|
||||
GLRenderToTexture* m_shadowMap;
|
||||
GLuint m_shadowTexture;
|
||||
|
||||
|
||||
InternalDataRenderer() :
|
||||
m_shadowMap(0),
|
||||
m_shadowTexture(0)
|
||||
@@ -223,8 +224,7 @@ static GLint ProjectionMatrixPointSprite=0;
|
||||
|
||||
|
||||
GLInstancingRenderer::GLInstancingRenderer(int maxNumObjectCapacity, int maxShapeCapacityInBytes)
|
||||
:m_maxNumObjectCapacity(maxNumObjectCapacity),
|
||||
m_maxShapeCapacityInBytes(maxShapeCapacityInBytes),
|
||||
:
|
||||
m_textureenabled(true),
|
||||
m_textureinitialized(false),
|
||||
m_screenWidth(0),
|
||||
@@ -234,14 +234,17 @@ GLInstancingRenderer::GLInstancingRenderer(int maxNumObjectCapacity, int maxShap
|
||||
{
|
||||
|
||||
m_data = new InternalDataRenderer;
|
||||
m_data->m_maxNumObjectCapacity = maxNumObjectCapacity;
|
||||
m_data->m_maxShapeCapacityInBytes=maxShapeCapacityInBytes;
|
||||
|
||||
m_data->m_totalNumInstances = 0;
|
||||
|
||||
sData2 = m_data;
|
||||
|
||||
m_data->m_instance_positions_ptr.resize(m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_quaternion_ptr.resize(m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_colors_ptr.resize(m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_scale_ptr.resize(m_maxNumObjectCapacity*3);
|
||||
m_data->m_instance_positions_ptr.resize(m_data->m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_quaternion_ptr.resize(m_data->m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_colors_ptr.resize(m_data->m_maxNumObjectCapacity*4);
|
||||
m_data->m_instance_scale_ptr.resize(m_data->m_maxNumObjectCapacity*3);
|
||||
|
||||
}
|
||||
|
||||
@@ -346,8 +349,8 @@ void GLInstancingRenderer::writeSingleInstanceTransformToGPU(float* position, fl
|
||||
|
||||
char* base = orgBase;
|
||||
|
||||
float* positions = (float*)(base+m_maxShapeCapacityInBytes);
|
||||
float* orientations = (float*)(base+m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE);
|
||||
float* positions = (float*)(base+m_data->m_maxShapeCapacityInBytes);
|
||||
float* orientations = (float*)(base+m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE);
|
||||
|
||||
|
||||
positions[objectIndex*4] = position[0];
|
||||
@@ -406,10 +409,10 @@ void GLInstancingRenderer::writeTransforms()
|
||||
|
||||
char* base = orgBase;
|
||||
|
||||
float* positions = (float*)(base+m_maxShapeCapacityInBytes);
|
||||
float* orientations = (float*)(base+m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE);
|
||||
float* colors= (float*)(base+m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE);
|
||||
float* scaling= (float*)(base+m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE);
|
||||
float* positions = (float*)(base+m_data->m_maxShapeCapacityInBytes);
|
||||
float* orientations = (float*)(base+m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE);
|
||||
float* colors= (float*)(base+m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE);
|
||||
float* scaling= (float*)(base+m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE);
|
||||
|
||||
//static int offset=0;
|
||||
//offset++;
|
||||
@@ -470,7 +473,7 @@ int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const double*
|
||||
int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
|
||||
{
|
||||
b3Assert(shapeIndex == (m_graphicsInstances.size()-1));
|
||||
b3Assert(m_graphicsInstances.size()<m_maxNumObjectCapacity-1);
|
||||
b3Assert(m_graphicsInstances.size()<m_data->m_maxNumObjectCapacity-1);
|
||||
|
||||
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
|
||||
|
||||
@@ -579,7 +582,7 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
||||
int sz = numvertices*vertexStrideInBytes;
|
||||
#ifdef B3_DEBUG
|
||||
int totalUsed = vertexStrideInBytes*gfxObj->m_vertexArrayOffset+sz;
|
||||
b3Assert(totalUsed<this->m_maxShapeCapacityInBytes);
|
||||
b3Assert(totalUsed<m_data->m_maxShapeCapacityInBytes);
|
||||
#endif//B3_DEBUG
|
||||
|
||||
memcpy(dest+vertexStrideInBytes*gfxObj->m_vertexArrayOffset,vertices,sz);
|
||||
@@ -611,10 +614,10 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices,
|
||||
void GLInstancingRenderer::InitShaders()
|
||||
{
|
||||
|
||||
int POSITION_BUFFER_SIZE = (m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int ORIENTATION_BUFFER_SIZE = (m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int COLOR_BUFFER_SIZE = (m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int SCALE_BUFFER_SIZE = (m_maxNumObjectCapacity*sizeof(float)*3);
|
||||
int POSITION_BUFFER_SIZE = (m_data->m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int ORIENTATION_BUFFER_SIZE = (m_data->m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int COLOR_BUFFER_SIZE = (m_data->m_maxNumObjectCapacity*sizeof(float)*4);
|
||||
int SCALE_BUFFER_SIZE = (m_data->m_maxNumObjectCapacity*sizeof(float)*3);
|
||||
|
||||
linesShader = gltLoadShaderPair(linesVertexShader,linesFragmentShader);
|
||||
lines_ModelViewMatrix = glGetUniformLocation(linesShader, "ModelViewMatrix");
|
||||
@@ -702,7 +705,7 @@ void GLInstancingRenderer::InitShaders()
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_data->m_vbo);
|
||||
|
||||
|
||||
int size = m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE+SCALE_BUFFER_SIZE;
|
||||
int size = m_data->m_maxShapeCapacityInBytes + POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE+SCALE_BUFFER_SIZE;
|
||||
m_data->m_vboSize = size;
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);//GL_STATIC_DRAW);
|
||||
@@ -1460,8 +1463,8 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 9*sizeof(float), vertex.m_pointer);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_maxShapeCapacityInBytes));
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE));
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes));
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE));
|
||||
|
||||
PointerCaster uv;
|
||||
uv.m_baseIndex = 7*sizeof(float)+vertex.m_baseIndex;
|
||||
@@ -1471,8 +1474,8 @@ b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 9*sizeof(float), uv.m_pointer);
|
||||
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, 9*sizeof(float), normal.m_pointer);
|
||||
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE));
|
||||
glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*3*sizeof(float)+m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE));
|
||||
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*4*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE));
|
||||
glVertexAttribPointer(6, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid *)(curOffset*3*sizeof(float)+m_data->m_maxShapeCapacityInBytes+POSITION_BUFFER_SIZE+ORIENTATION_BUFFER_SIZE+COLOR_BUFFER_SIZE));
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
@@ -1630,3 +1633,11 @@ void GLInstancingRenderer::enableShadowMap()
|
||||
|
||||
}
|
||||
|
||||
int GLInstancingRenderer::getMaxShapeCapacity() const
|
||||
{
|
||||
return m_data->m_maxShapeCapacityInBytes;
|
||||
}
|
||||
int GLInstancingRenderer::getInstanceCapacity() const
|
||||
{
|
||||
return m_data->m_maxNumObjectCapacity;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ class GLInstancingRenderer : public CommonRenderInterface
|
||||
|
||||
b3AlignedObjectArray<struct b3GraphicsInstance*> m_graphicsInstances;
|
||||
|
||||
int m_maxNumObjectCapacity;
|
||||
int m_maxShapeCapacityInBytes;
|
||||
|
||||
struct InternalDataRenderer* m_data;
|
||||
|
||||
bool m_textureenabled;
|
||||
@@ -94,7 +93,7 @@ public:
|
||||
virtual void writeSingleInstanceColorToCPU(double* color, int srcIndex);
|
||||
|
||||
|
||||
struct GLInstanceRendererInternalData* getInternalData();
|
||||
virtual struct GLInstanceRendererInternalData* getInternalData();
|
||||
|
||||
virtual void drawLine(const float from[4], const float to[4], const float color[4], float lineWidth=1);
|
||||
virtual void drawLine(const double from[4], const double to[4], const double color[4], double lineWidth=1);
|
||||
@@ -119,14 +118,10 @@ public:
|
||||
return m_screenHeight;
|
||||
}
|
||||
|
||||
virtual int getMaxShapeCapacity() const
|
||||
{
|
||||
return m_maxShapeCapacityInBytes;
|
||||
}
|
||||
virtual int getInstanceCapacity() const
|
||||
{
|
||||
return m_maxNumObjectCapacity;
|
||||
}
|
||||
virtual int getMaxShapeCapacity() const;
|
||||
|
||||
virtual int getInstanceCapacity() const;
|
||||
|
||||
virtual void enableShadowMap();
|
||||
virtual void enableBlend(bool blend)
|
||||
{
|
||||
|
||||
@@ -822,7 +822,7 @@ void MacOpenGLWindow::startRendering()
|
||||
uint32 virtualKeycode = [event keyCode];
|
||||
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(virtualKeycode);
|
||||
printf("keycode = %d\n", keycode);
|
||||
// printf("keycode = %d\n", keycode);
|
||||
|
||||
if (m_keyboardCallback)
|
||||
{
|
||||
@@ -839,7 +839,7 @@ void MacOpenGLWindow::startRendering()
|
||||
uint32 virtualKeycode = [event keyCode];
|
||||
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(virtualKeycode);
|
||||
printf("keycode = %d\n", keycode);
|
||||
//printf("keycode = %d\n", keycode);
|
||||
|
||||
if (m_keyboardCallback)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,11 @@ struct SimpleOpenGL2Renderer : public CommonRenderInterface
|
||||
virtual void updateShape(int shapeIndex, const float* vertices);
|
||||
|
||||
virtual void enableBlend(bool blend);
|
||||
|
||||
virtual struct GLInstanceRendererInternalData* getInternalData()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
#endif //SIMPLE_OPENGL2_RENDERER_H
|
||||
|
||||
@@ -157,13 +157,13 @@ int Win32OpenGLWindow::fileOpenDialog(char* fileName, int maxFileNameLength)
|
||||
ofn.lpstrFile = bla;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = 1023;
|
||||
ofn.lpstrFilter = L"URDF\0*.urdf\0";
|
||||
ofn.lpstrFilter = L"All Files\0*.*\0URDF\0*.urdf\0.bullet\0*.bullet\0";
|
||||
#else
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = 1023;
|
||||
//ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
|
||||
ofn.lpstrFilter = "URDF\0*.urdf\0";
|
||||
ofn.lpstrFilter = "All Files\0*.*\0URDF\0*.urdf\0.bullet\0*.bullet\0";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -57,21 +57,14 @@ void Win32Window::pumpMessage()
|
||||
};
|
||||
}
|
||||
|
||||
int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
|
||||
int getSpecialKeyFromVirtualKeycode(int virtualKeyCode)
|
||||
{
|
||||
int keycode = 0xffffffff;
|
||||
if (virtualKeyCode >= '0' && virtualKeyCode <= '9')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
if (virtualKeyCode >= 'a' && virtualKeyCode <= 'z')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
int keycode = -1;
|
||||
if (virtualKeyCode >= 'A' && virtualKeyCode <= 'Z')
|
||||
{
|
||||
return virtualKeyCode+32;//todo: fix the ascii A vs a input
|
||||
}
|
||||
|
||||
switch (virtualKeyCode)
|
||||
{
|
||||
case VK_RETURN: {keycode = B3G_RETURN; break; };
|
||||
@@ -113,6 +106,24 @@ int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
|
||||
return keycode;
|
||||
}
|
||||
|
||||
|
||||
int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
|
||||
{
|
||||
int keycode = 0xffffffff;
|
||||
|
||||
if (virtualKeyCode >= 'a' && virtualKeyCode <= 'z')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
|
||||
if (virtualKeyCode >= 'A' && virtualKeyCode <= 'Z')
|
||||
{
|
||||
return virtualKeyCode+32;//todo: fix the ascii A vs a input
|
||||
}
|
||||
|
||||
return keycode;
|
||||
}
|
||||
|
||||
bool Win32Window::isModifierKeyPressed(int key)
|
||||
{
|
||||
bool isPressed = false;
|
||||
@@ -176,7 +187,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_KEYUP:
|
||||
{
|
||||
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
|
||||
int keycode = getSpecialKeyFromVirtualKeycode(wParam);
|
||||
switch (keycode)
|
||||
{
|
||||
case B3G_ALT:
|
||||
@@ -220,7 +231,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
|
||||
int keycode = getSpecialKeyFromVirtualKeycode(wParam);
|
||||
switch (keycode)
|
||||
{
|
||||
case B3G_ALT:
|
||||
|
||||
@@ -93,7 +93,14 @@ class Planar2D : public CommonRigidBodyBase
|
||||
|
||||
void exitPhysics();
|
||||
|
||||
|
||||
void resetCamera()
|
||||
{
|
||||
float dist = 9;
|
||||
float pitch = 539;
|
||||
float yaw = 11;
|
||||
float targetPos[3]={8.6,10.5,-20.6};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -325,7 +332,7 @@ void Planar2D::exitPhysics()
|
||||
m_box2dbox2dAlgo = 0;
|
||||
}
|
||||
|
||||
CommonExampleInterface* Planar2DCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new Planar2D(helper);
|
||||
return new Planar2D(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef PLANAR2D_H
|
||||
#define PLANAR2D_H
|
||||
|
||||
class CommonExampleInterface* Planar2DCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* Planar2DCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //BOX2D_DEMO_H
|
||||
|
||||
|
||||
@@ -52,7 +52,14 @@ public:
|
||||
|
||||
virtual void stepSimulation(float deltaTime);
|
||||
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 18;
|
||||
float pitch = 129;
|
||||
float yaw = 30;
|
||||
float targetPos[3]={-4.6,-4.7,-5.75};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -147,6 +154,7 @@ void RaytestDemo::castRays()
|
||||
|
||||
void RaytestDemo::initPhysics()
|
||||
{
|
||||
m_guiHelper->setUpAxis(1);
|
||||
|
||||
///collision configuration contains default setup for memory, collision setup
|
||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
@@ -318,9 +326,9 @@ void RaytestDemo::exitPhysics()
|
||||
|
||||
}
|
||||
|
||||
class CommonExampleInterface* RaytestCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* RaytestCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new RaytestDemo(helper);
|
||||
return new RaytestDemo(options.m_guiHelper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef BT_RAYTEST_DEMO_H
|
||||
#define BT_RAYTEST_DEMO_H
|
||||
|
||||
class CommonExampleInterface* RaytestCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* RaytestCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //BT_RAYTEST_DEMO_H
|
||||
|
||||
@@ -138,11 +138,26 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 3.5;
|
||||
float pitch = 136;
|
||||
float yaw = 32;
|
||||
float targetPos[3]={0,0,0};
|
||||
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
|
||||
{
|
||||
m_app->m_renderer->getActiveCamera()->setCameraDistance(dist);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraPitch(pitch);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraYaw(yaw);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraTargetPosition(targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct CommonExampleInterface* CoordinateSystemCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
struct CommonExampleInterface* CoordinateSystemCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new CoordinateSystemDemo(helper->getAppInterface());
|
||||
return new CoordinateSystemDemo(options.m_guiHelper->getAppInterface());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef COORDINATE_SYSTEM_DEMO_H
|
||||
#define COORDINATE_SYSTEM_DEMO_H
|
||||
|
||||
class CommonExampleInterface* CoordinateSystemCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* CoordinateSystemCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //COORDINATE_SYSTEM_DEMO_H
|
||||
|
||||
@@ -378,7 +378,7 @@ void RaytracerPhysicsSetup::syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBrid
|
||||
{
|
||||
}
|
||||
|
||||
CommonExampleInterface* RayTracerCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* RayTracerCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new RaytracerPhysicsSetup(helper->getAppInterface());
|
||||
return new RaytracerPhysicsSetup(options.m_guiHelper->getAppInterface());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef RAYTRACER_SETUP_H
|
||||
#define RAYTRACER_SETUP_H
|
||||
|
||||
class CommonExampleInterface* RayTracerCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* RayTracerCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //RAYTRACER_SETUP_H
|
||||
|
||||
@@ -125,12 +125,27 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 13;
|
||||
float pitch = 50;
|
||||
float yaw = 13;
|
||||
float targetPos[3]={-1,0,-0.3};
|
||||
if (m_app->m_renderer && m_app->m_renderer->getActiveCamera())
|
||||
{
|
||||
m_app->m_renderer->getActiveCamera()->setCameraDistance(dist);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraPitch(pitch);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraYaw(yaw);
|
||||
m_app->m_renderer->getActiveCamera()->setCameraTargetPosition(targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CommonExampleInterface* RenderInstancingCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* RenderInstancingCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new RenderInstancingDemo(helper->getAppInterface());
|
||||
return new RenderInstancingDemo(options.m_guiHelper->getAppInterface());
|
||||
}
|
||||
|
||||
#endif //RENDER_INSTANCING_DEMO_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef RENDER_INSTANCING_DEMO_H
|
||||
#define RENDER_INSTANCING_DEMO_H
|
||||
|
||||
class CommonExampleInterface* RenderInstancingCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* RenderInstancingCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //RENDER_INSTANCING_DEMO_H
|
||||
|
||||
@@ -103,6 +103,16 @@ public:
|
||||
|
||||
void exitPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
//@todo depends on current_demo?
|
||||
float dist = 45;
|
||||
float pitch = 27;
|
||||
float yaw = 31;
|
||||
float targetPos[3]={10-1,0};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
SoftDemo(struct GUIHelperInterface* helper)
|
||||
: CommonRigidBodyBase(helper),
|
||||
m_drag(false)
|
||||
@@ -150,6 +160,22 @@ public:
|
||||
{
|
||||
return m_guiHelper;
|
||||
}
|
||||
|
||||
virtual void renderScene()
|
||||
{
|
||||
CommonRigidBodyBase::renderScene();
|
||||
btSoftRigidDynamicsWorld* softWorld = getSoftDynamicsWorld();
|
||||
|
||||
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
|
||||
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||
{
|
||||
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
|
||||
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2322,10 +2348,10 @@ void SoftDemo::exitPhysics()
|
||||
}
|
||||
|
||||
|
||||
class CommonExampleInterface* SoftDemoCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
class CommonExampleInterface* SoftDemoCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
current_demo = option;
|
||||
return new SoftDemo(helper);
|
||||
current_demo = options.m_option;
|
||||
return new SoftDemo(options.m_guiHelper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
||||
#ifndef SOFT_DEMO_H
|
||||
#define SOFT_DEMO_H
|
||||
|
||||
class CommonExampleInterface* SoftDemoCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* SoftDemoCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
|
||||
#endif //CCD_PHYSICS_DEMO_H
|
||||
|
||||
@@ -118,6 +118,15 @@ class Hinge2Vehicle : public CommonRigidBodyBase
|
||||
void initPhysics();
|
||||
void exitPhysics();
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 8;
|
||||
float pitch = -45;
|
||||
float yaw = 32;
|
||||
float targetPos[3]={-0.33,-0.72,4.5};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
/*static DemoApplication* Create()
|
||||
{
|
||||
Hinge2Vehicle* demo = new Hinge2Vehicle();
|
||||
@@ -1170,7 +1179,7 @@ btRigidBody* Hinge2Vehicle::localCreateRigidBody(btScalar mass, const btTransfor
|
||||
return body;
|
||||
}
|
||||
|
||||
CommonExampleInterface* Hinge2VehicleCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* Hinge2VehicleCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new Hinge2Vehicle(helper);
|
||||
return new Hinge2Vehicle(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
||||
#ifndef HINGE2_VEHICLE_H
|
||||
#define HINGE2_VEHICLE_H
|
||||
|
||||
class CommonExampleInterface* Hinge2VehicleCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* Hinge2VehicleCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif // HINGE2_VEHICLE_H
|
||||
|
||||
|
||||
@@ -105,7 +105,14 @@ class VoronoiFractureDemo : public CommonRigidBodyBase
|
||||
|
||||
void attachFixedConstraints();
|
||||
|
||||
|
||||
virtual void resetCamera()
|
||||
{
|
||||
float dist = 18;
|
||||
float pitch = 129;
|
||||
float yaw = 30;
|
||||
float targetPos[3]={-1.5,4.7,-2};
|
||||
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -817,7 +824,7 @@ static DemoApplication* Create()
|
||||
|
||||
*/
|
||||
|
||||
CommonExampleInterface* VoronoiFractureCreateFunc(PhysicsInterface* pint, GUIHelperInterface* helper, int option)
|
||||
CommonExampleInterface* VoronoiFractureCreateFunc(struct CommonExampleOptions& options)
|
||||
{
|
||||
return new VoronoiFractureDemo(helper);
|
||||
return new VoronoiFractureDemo(options.m_guiHelper);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
#ifndef VORONOI_FRACTURE_DEMO_H
|
||||
#define VORONOI_FRACTURE_DEMO_H
|
||||
|
||||
class CommonExampleInterface* VoronoiFractureCreateFunc(struct PhysicsInterface* pint, struct GUIHelperInterface* helper, int option);
|
||||
class CommonExampleInterface* VoronoiFractureCreateFunc(struct CommonExampleOptions& options);
|
||||
|
||||
#endif //VORONOI_FRACTURE_DEMO_H
|
||||
|
||||
|
||||
@@ -1031,9 +1031,9 @@ void b3GpuSapBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
|
||||
if (m_dst.size()!=(numSmallAabbs+1))
|
||||
{
|
||||
m_dst.resize(numSmallAabbs+1);
|
||||
m_sum.resize(numSmallAabbs+1);
|
||||
m_sum2.resize(numSmallAabbs+1);
|
||||
m_dst.resize(numSmallAabbs+128);
|
||||
m_sum.resize(numSmallAabbs+128);
|
||||
m_sum2.resize(numSmallAabbs+128);
|
||||
m_sum.at(numSmallAabbs)=b3MakeVector3(0,0,0); //slow?
|
||||
m_sum2.at(numSmallAabbs)=b3MakeVector3(0,0,0); //slow?
|
||||
}
|
||||
@@ -1044,8 +1044,8 @@ void b3GpuSapBroadphase::calculateOverlappingPairs(int maxPairs)
|
||||
launcher.setBuffer(m_smallAabbsMappingGPU.getBufferCL());
|
||||
launcher.setBuffer(m_sum.getBufferCL());
|
||||
launcher.setBuffer(m_sum2.getBufferCL());
|
||||
launcher.setConst( numSmallAabbs+1 );
|
||||
int num = numSmallAabbs+1;
|
||||
launcher.setConst( numSmallAabbs );
|
||||
int num = numSmallAabbs;
|
||||
launcher.launch1D( num);
|
||||
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ __kernel void scatterKernel( __global const btAabbCL* allAabbs, __global const
|
||||
__kernel void prepareSumVarianceKernel( __global const btAabbCL* allAabbs, __global const int* smallAabbMapping, __global float4* sum, __global float4* sum2,int numAabbs)
|
||||
{
|
||||
int i = get_global_id(0);
|
||||
if (i>numAabbs)
|
||||
if (i>=numAabbs)
|
||||
return;
|
||||
|
||||
btAabbCL smallAabb = allAabbs[smallAabbMapping[i]];
|
||||
|
||||
@@ -329,7 +329,7 @@ static const char* sapCL= \
|
||||
"__kernel void prepareSumVarianceKernel( __global const btAabbCL* allAabbs, __global const int* smallAabbMapping, __global float4* sum, __global float4* sum2,int numAabbs)\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" if (i>numAabbs)\n"
|
||||
" if (i>=numAabbs)\n"
|
||||
" return;\n"
|
||||
" \n"
|
||||
" btAabbCL smallAabb = allAabbs[smallAabbMapping[i]];\n"
|
||||
|
||||
@@ -1193,17 +1193,23 @@ inline void btDbvt::collideOCL( const btDbvtNode* root,
|
||||
/* Insert 0 */
|
||||
j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
|
||||
stack.push_back(0);
|
||||
|
||||
//void * memmove ( void * destination, const void * source, size_t num );
|
||||
|
||||
#if DBVT_USE_MEMMOVE
|
||||
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
|
||||
memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1));
|
||||
#else
|
||||
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
|
||||
for(int k=stack.size()-1;k>j;--k)
|
||||
{
|
||||
stack[k]=stack[k-1];
|
||||
}
|
||||
#endif
|
||||
stack[j]=allocate(ifree,stock,nes[q]);
|
||||
/* Insert 1 */
|
||||
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
|
||||
stack.push_back(0);
|
||||
#if DBVT_USE_MEMMOVE
|
||||
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
|
||||
memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1));
|
||||
#else
|
||||
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user