main() blog

プログラムやゲーム、旅、愛する家族について綴っていきます。

ゲームエンジンのプログラム構成の比較

はじめに

ゲームエンジン物理エンジンミドルウェアのコーディング規約やファイル命名規則など比較してみる。 論理構成(フォルダ構成やリソースの命名規則等も含めて)においても問題になってくる話。

以下の項目について確認していく。

  • バージョン
  • ファイル命名規則
  • ファイル文字コード
  • フォルダ構成
  • libファイル命名規則
  • ファイルヘッダ
  • コメント
  • インクルードガード
  • プラットフォーム定義
  • 型定義
  • 名前空間
  • クラス名
  • 関数名
  • 変数名
  • new,allocator
  • TRACE,ASSERT

命名規則については以下の規則のいずれかが適用されている。

  • CamelCase(PascalCase)
    パスカルケース/アッパーキャメルケース(複合語の先頭を大文字にする)

  • camelCase
    キャメルケース/ローワーキャメルケース(複合号の先頭を小文字にする)

  • snake_case
    スネークケース(全て小文字で複合語の間にアンダーバー"_"を入れる)

OGRE

OGRE (Object-Oriented Graphics Rendering Engine) は、シーン指向の柔軟な3次元レンダリングエンジンで、ハードウェアアクセラレーションを活用した3Dグラフィックスのアプリケーションを容易に開発できるよう設計されC++で書かれている。Direct3DOpenGLなどの下位のシステムライブラリの詳細を抽象化したクラスライブラリであり、ワールドオブジェクトなどの高度なクラスに基づくインタフェースを提供する。

■バージョン

1.10.9

■ファイル命名規則

CamelCase

Ogre.h OgreAnimation.h

■フォルダ構成

\Ogre
    \CMake
    \Components
    \Docs
    \OgreMain
        \include
            \Android
            \Emscripten
            \iOS
            \OSX
            \Threading
            \WIN32
        \stc
            \Android
            \Emscripten
            \GLX
            \iOS
            \nedmalloc
            \stbi
            \Threading
            \WIN32
    \Other
    \PlugIns
        \BSPScnenManager
        \CgProgramManager
        \EXRCodec
        \OctreeSceneManager
        \OctreeZone
        \ParticleFX
        \PCZSceneManager
    \RenderSystem
        \Direct3D11
        \Direct3D9
        \GL
        \GL3Plus
        \GLES
        \GLES2
        \GLSupport
    \Samples
    \SDK
    \Tests
    \Tools

■libファイル命名規則

■ファイルヘッダ

/*
-----------------------------------------------------------------------------
This source file is part of OGRE
    (Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2014 Torus Knot Software Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

■インクルードガード

#ifndef _Ogre_H__
#define _Ogre_H__
#ifndef __Animation_H__
#define __Animation_H__
#ifndef __Bone_H__
#define __Bone_H__

■型定義

uint32やuintが定義が混在している。 実数はRealという型が定義されている。

Ogreというnamespaceで括られている。

boolはそのまま。 ソースを見るとintやfloatなどがそのまま使用されている箇所もある。

namespace Ogre {

// Integer formats of fixed bit width
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef int int32;
typedef short int16;
typedef signed char int8;
// define uint64 type
#if OGRE_COMPILER == OGRE_COMPILER_MSVC
    typedef unsigned __int64 uint64;
    typedef __int64 int64;
#else
    typedef unsigned long long uint64;
    typedef long long int64;
#endif
}
namespace Ogre {
    // define the real number values to be used
    // default to use 'float' unless precompiler option set
    #if OGRE_DOUBLE_PRECISION == 1
        /** Software floating point type.
        @note Not valid as a pointer to GPU buffers / parameters
        */
        typedef double Real;
    #else
        /** Software floating point type.
        @note Not valid as a pointer to GPU buffers / parameters
        */
        typedef float Real;
    #endif

    /** In order to avoid finger-aches :)
    */
    typedef unsigned char uchar;
    typedef unsigned short ushort;
    typedef unsigned int uint;
    typedef unsigned long ulong;
}

namespaceで括られているので実際に書くときには冗長気味。

void hoge()
{
    Ogre::uint32 ui32 = 0;
    Ogre::int8 i8 = 0;
    Ogre::Real real = 0.0f;
}

名前空間

namespace Ogreのみ。 機能毎にnamespace等で分けてはいない。

namespace Ogre
{
}

■class名,struct名

CamelCase。

    class _OgreExport MeshManager: public ResourceManager, public Singleton<MeshManager>, 
        public ManualResourceLoader
    {
    };

■関数名

camelCase。

        getByName(const String& name, const String& groupName);

■変数名

camelCase。 メンバー変数場合はハンガリアン表記と思われる"m"が頭に付く。

        // element type for blend weights in vertex buffer (VET_UBYTE4, VET_USHORT1, or VET_FLOAT1)
        VertexElementType mBlendWeightsBaseElementType;

        bool mPrepAllMeshesForShadowVolumes;
    
        //the factor by which the bounding box of an entity is padded   
        Real mBoundsPaddingFactor;

■TRACE,ASSERT

TRACEはLogManagerのlogMessage()を使用している模様。 普通に関数呼出ししているけどrelease時とかでログは消えているのか? この実装だと関数呼び出しは無くならないような気がする。

        LogManager::getSingleton().logMessage("ArchiveFactory for archive type " +     factory->getType() + " registered.");

ASSERTはOrgeAssertというマクロが用意されている。

#   define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNCTION__ )

irrlicht

読み方が分からない...

Irrlicht Engine は、C++で書かれたオープンソースの3次元ゲームエンジン。公式にも WindowsmacOSLinuxWindows CEクロスプラットフォームで動作し、そのオープンな性質からXboxPlayStation PortableSymbian OSiPhoneGoogle Native Clientにも移植されている。 Irrlichtは、オブジェクトが小さく、各種ハードウェアへの移植性・互換性が高く、学習が容易で、コミュニティが活発である。非公式の各種言語バインディングにより、.NET、JavaPerlRubyPython、FreeBASIC、LuaDelphiC++ Builder、AutoIt、Game Maker などに対応している。 Irrlichtの開発は2003年に Nikolaus Gebhardt がたった1人で始めた。2006年に 1.0 をリリースすると、開発チームは10人となった

■バージョン

1.8.4

■ファイル命名規則

基本はCamelCase。 一部camelCase、snake_caseが混在。

classとinterface,enumでファイル名を分けている。 コーディング規約の命名がそのままファイル名になっている模様。 classは"C"、interfaceは"I"、enumは"E"と付ける。 一部はエンジンの名称の略称の"irr"を付ける。

CVertexBuff.h EAttribute.h IAnimatedMesh.h irrAllocator.h

■フォルダ構成

\irrlicht-1.8.4
    \bin
    \doc
    \examples
    \include
    \lib
        \Linux
        \MacOSX
        \Win32-gcc
        \Win32-visualstudio
        \Win64-visualstudio
    \media
    \source
        \Irrlicht
            \aesGladman
            \bzip2
            \jpeglib
            \lzma
            \MacOSX
            \zlib
    \tools

■libファイル命名規則

■ファイルヘッダ

// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

■インクルードガード

#ifndef __IRR_TYPES_H_INCLUDED__
#define __IRR_TYPES_H_INCLUDED__

■型定義

namespace irr
{

//! 8 bit unsigned variable.
/** This is a typedef for unsigned char, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef unsigned __int8     u8;
#else
typedef unsigned char       u8;
#endif

//! 8 bit signed variable.
/** This is a typedef for signed char, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef __int8          s8;
#else
typedef signed char     s8;
#endif

//! 8 bit character variable.
/** This is a typedef for char, it ensures portability of the engine. */
typedef char            c8;



//! 16 bit unsigned variable.
/** This is a typedef for unsigned short, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef unsigned __int16    u16;
#else
typedef unsigned short      u16;
#endif

//! 16 bit signed variable.
/** This is a typedef for signed short, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef __int16         s16;
#else
typedef signed short        s16;
#endif



//! 32 bit unsigned variable.
/** This is a typedef for unsigned int, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef unsigned __int32    u32;
#else
typedef unsigned int        u32;
#endif

//! 32 bit signed variable.
/** This is a typedef for signed int, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef __int32         s32;
#else
typedef signed int      s32;
#endif


#ifdef __IRR_HAS_S64
//! 64 bit unsigned variable.
/** This is a typedef for 64bit uint, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef unsigned __int64            u64;
#elif __GNUC__
#if __WORDSIZE == 64
typedef unsigned long int           u64;
#else
__extension__ typedef unsigned long long    u64;
#endif
#else
typedef unsigned long long          u64;
#endif

//! 64 bit signed variable.
/** This is a typedef for 64bit int, it ensures portability of the engine. */
#if defined(_MSC_VER) || ((__BORLANDC__ >= 0x530) && !defined(__STRICT_ANSI__))
typedef __int64                 s64;
#elif __GNUC__
#if __WORDSIZE == 64
typedef long int                s64;
#else
__extension__ typedef long long         s64;
#endif
#else
typedef long long               s64;
#endif
#endif  // __IRR_HAS_S64



//! 32 bit floating point variable.
/** This is a typedef for float, it ensures portability of the engine. */
typedef float               f32;

//! 64 bit floating point variable.
/** This is a typedef for double, it ensures portability of the engine. */
typedef double              f64;


} // end namespace irr

名前空間

namespace irr
{

namespace core
{
}

namespace video
{
}
namespace scene
{
}

}

■class名,struct名

CamelCase。 classの場合は"C"、interfaceの場合は"I"を付ける。

namespace irr
{
namespace scene
{
    class IAnimatedMesh : public IMesh
    {

■関数名

camelCase

■変数名

classのメンバ変数はCamelCase。 auto変数などはcamelCase。

■TRACE,ASSERT

ASSERTは"_IRR_DEBUG_BREAK_IF"というマクロを使用。

//! define a break macro for debugging.
#if defined(_DEBUG)
#if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE)
  #if defined(WIN64) || defined(_WIN64) // using portable common solution for x64 configuration
  #include <crtdbg.h>
  #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();}
  #else
  #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3}
  #endif
#else
#include "assert.h"
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) );
#endif
#else
#define _IRR_DEBUG_BREAK_IF( _CONDITION_ )
#endif

CrystalSpace

Crystal Space は3Dアプリケーション開発のためのフレームワークであり、Jorrit Tyberghein がC++で開発した。最初の一般へのリリースは1997年8月26日[1]。ゲームエンジンとしての利用が一般的だが、より汎用的なフレームワークとして各種3D視覚化に使うことができる。移植性が高く、Microsoft WindowsGNU/LinuxUNIXMac OS X で動作する。GNU Lesser General Public License でライセンスされたフリーソフトウェアであり、2003年2月にはSourceForge.netで Project of the Month に選ばれている[2]。

オプションでOpenGL(全プラットフォーム)、SDLSDLのある全プラットフォーム)、X11UNIXおよびGNU/Linux)、SVGALib(GNU/Linux)を使える。オプションでNASMとMMXを使ったアセンブリ言語ルーチンも使える。

■バージョン

2.0

■ファイル命名規則

snake_case

■フォルダ構成

■libファイル命名規則

■ファイルヘッダ

/*
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
  
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

■インクルードガード

#ifndef __CRYSTALSPACE_H__
#define __CRYSTALSPACE_H__

■型定義

namespaceでは括られていない。

/**\name Specific sized types
 * These types should be used ONLY when you need a variable of an explicit
 * number of bits.  For all other cases, you should use normal char, short,
 * int, long, etc., types since they are treated as "natural" types and will
 * generally have better performance characteristics than the explicitly-sized
 * types. Use the explicitly-sized types sparingly.
 * @{ */

#if !defined(CS_HAVE_STDINT_H) && !defined(CS_HAVE_INTTYPES_H)
/// unsigned 8-bit integer (0..255)
typedef unsigned char uint8;
/// signed 8-bit integer (-128..127)
typedef char int8;
/// unsigned 16-bit integer (0..65 535)
typedef unsigned short uint16;
/// signed 16-bit integer (-32 768..32 767)
typedef short int16;
/// unsigned 32-bit integer (0..4 294 967 295)
typedef unsigned int uint32;
/// signed 32-bit integer (-2 147 483 648..2 147 483 647)
typedef int int32;
#if defined(CS_COMPILER_GCC)
#ifndef __STRICT_ANSI__
/// unsigned 64-bit integer
typedef unsigned long long uint64;
/// signed 64-bit integer
typedef long long int64;
#endif
#elif defined(CS_COMPILER_MSVC) || defined(CS_COMPILER_BCC)
/// unsigned 64 bit integer
typedef unsigned __int64 uint64;
/// signed 64 bit integer
typedef __int64 int64;
#else
#error Do not know how to declare 64-bit integers
#endif // CS_COMPILER_GCC

#else // CS_HAVE_STDINT_H || CS_HAVE_INTTYPES_H

typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
typedef int16_t int16;
typedef uint32_t uint32;
typedef int32_t int32;
typedef uint64_t uint64;
typedef int64_t int64;
#endif

コメントの訳。

特定のサイズの種類 これらの型は、明示的なビット数の変数が必要な場合にのみ使用する必要があります。 それ以外の場合は、通常のchar型、short型、int型、long型などの型を使用するべきです。 なぜなら、それらは "自然な"型として扱われ、一般的に明示的なサイズの型よりも優れたパフォーマンス特性を持つからです。 明示的にサイズの指定された型は慎重に使用してください。

本当か?

名前空間

namespacedocs.hに全てのnamespaceが書かれている。

/** \file
 * Documentation for namespaces in CS
 */

/**
 * Main namespace for CrystalSpace
 */
namespace CS
{
  /**
   * Animation-related types  
   */
  namespace Animation
  {}

  /**
   * Checksums and message digests
   */
  namespace Checksum
  {}

    :
    :

■class名,struct名

CamelCase

■関数名

CamelCase

  public:
    /// Construct.
    RenderView ();
    /// Construct.
    RenderView (iCamera* c);
    /// Construct.
    RenderView (iCamera* c, iClipper2D* v, iGraphics3D* ig3d);
    /// Construct.
    RenderView (iView* v);
    /// Copy constructor.
    RenderView (const RenderView& other);
    /// Copy constructor, optionally keeping the camera
    RenderView (const RenderView& other, bool keepCamera);

    virtual ~RenderView ();

    /// Initialise the RenderView from an iView.
    void InitialiseFromView (iView* view);

    /// Initialise the RenderView from an iCamera.
    void InitialiseFromCamera (iCamera* camera);

    /// Set the engine.
    void SetEngine (iEngine* engine);
    /// Set the camera.
    void SetCamera (iCamera* camera);
    /// Set the original camera.
    void SetOriginalCamera (iCamera* camera);
    /// Get the original camera.
    virtual iCamera* GetOriginalCamera () const { return original_camera; }

■変数名

snake_case

    /**
    * The following id is used to populate the context_id in every
    * csRenderContext.
    */
    uint32 context_id;

    /// The current render context.
    csRenderContext* ctxt;

    /// Engine handle.
    iEngine* engine;
    /// The 3D graphics subsystem used for drawing.
    iGraphics3D* g3d;
    /// The 2D graphics subsystem used for drawing.
    iGraphics2D* g2d;
    /**
     * A copy to the original base camera before space warping.
     */
    iCamera* original_camera;

■new,allocator

cs_mallocというものもを用意している模様... ptmalloc_wrap.cppあたりに実装がある。

■TRACE,ASSERT

CS_ASSERTというマクロが用意されている。

#if defined(CS_DEBUG) || defined(CS_WITH_ASSERTIONS)
#  define CS_DEBUG_BREAK    CS::Debug::DebugBreak()
#  if !defined (CS_ASSERT_MSG)
#   define CS_ASSERT_MSG(msg,x)                     \
      if (!(x)) CS::Debug::AssertMessage (#x, __FILE__, __LINE__, msg);
#  endif
#  if !defined (CS_ASSERT)
#    define CS_ASSERT(x)    CS_ASSERT_MSG(0, x)
#  endif
#else
#  undef  CS_DEBUG_BREAK
#  define CS_DEBUG_BREAK
#  undef  CS_ASSERT
#  define CS_ASSERT(x)      (void)0
#  undef  CS_ASSERT_MSG
#  define CS_ASSERT_MSG(m,x)    (void)0
#endif

OpenSceneGraph

OpenSceneGraphは、OpenGLオープンソースのライブラリおよび3Dツールキットである。主として、コンピューターゲームバーチャルリアリティの開発をターゲットとしている。

プログラミング言語は標準のC++OpenGLを、完全にサポートしている。

■バージョン

3.4.1

■ファイル命名規則

CamelCase

ヘッダファイルに拡張子が無い。 C++の標準ヘッダの仕様に合わせている?

include\
    osg\
        AlphaFunc
        AnimationPath
        ApplicationUsage
        ArgumentParser
        Array
            :
            :

拡張子無いとgrepとかで検索する時にファイルで絞り込めない。

■フォルダ構成

■libファイル命名規則

■ファイルヘッダ

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

■インクルードガード

#ifndef __OSG_TYPES
#define __OSG_TYPES

■型定義

組み込みの型をそのまま使用している。 型のサイズについてはVisualCの時のみ再定義している模様... VisualStudioのバージョンで判断して、C++11以前のコンパイラの場合に C++11以降で標準で定義されてり型を定義し直している。

#if defined(_MSC_VER) && _MSC_VER < 1600
typedef signed __int8    int8_t;
typedef unsigned __int8  uint8_t;
typedef signed __int16   int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32   int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64   int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif

名前空間

フォルダ毎にそれぞれがnamespaceになっている模様...

osg\

namespace osg
{
}

osgAnimation\

namespace osgAnimation
{
}

■class名,struct名

CamelCase

■関数名

camelCase

■変数名

camelCase。 メンバ変数の場合は頭に"_"を付ける。

namespace osgAnimation
{

    // A bone can't have more than one parent Bone, so sharing a part of Bone's hierarchy
    // makes no sense. You can share the entire hierarchy but not only a part of it.
    class OSGANIMATION_EXPORT Bone : public osg::MatrixTransform
    {
    public:
        typedef osg::Matrix MatrixType;

        META_Node(osgAnimation, Bone);
        Bone(const Bone& b, const osg::CopyOp& copyop= osg::CopyOp::SHALLOW_COPY);
        Bone(const std::string& name = "");

        void setDefaultUpdateCallback(const std::string& name = "");

        Bone* getBoneParent();
        const Bone* getBoneParent() const;

        const osg::Matrix& getMatrixInBoneSpace() const { return getMatrix();}
        const osg::Matrix& getMatrixInSkeletonSpace() const { return _boneInSkeletonSpace; }
        const osg::Matrix& getInvBindMatrixInSkeletonSpace() const { return _invBindInSkeletonSpace;}
        void setMatrixInSkeletonSpace(const osg::Matrix& matrix) { _boneInSkeletonSpace = matrix; }
        void setInvBindMatrixInSkeletonSpace(const osg::Matrix& matrix) { _invBindInSkeletonSpace = matrix; }

    protected:

        // bind data
        osg::Matrix _invBindInSkeletonSpace;

        // bone updated
        osg::Matrix _boneInSkeletonSpace;
    };

    typedef std::map<std::string, osg::ref_ptr<Bone> > BoneMap;
}

■TRACE,ASSERT

基本的にはC++標準のassert()を使用。

UnrealEngine

■バージョン

■ファイル命名規則

■フォルダ構成

■libファイル命名規則

■ファイルヘッダ

■インクルードガード

■型定義

名前空間

■class名,struct名

■関数名

■変数名

■TRACE,ASSERT

Havok

Havok Physics(ハボックフィジックス、単にHavokとも)は、アイルランドのHavok社が開発した物理エンジンミドルウェアである。

■バージョン

■ファイル命名規則

camelCase。 頭に"hk"や"hcl"などの小文字の略称名が付く。

hkBase.h hclCloth.h hkcdCollide.h

■フォルダ構成

\havok
    \Build
    \Lib
        \xxx_vs2012_noRtti
        \x64_vs2015
            \debug
            \dev
            \release
    \Source
        \Ai
        \Cloth
        \Common
        \ContentTools
        \Geometry
    \Tools
    \Workspace

■libファイル命名規則

camelCase。 頭に"hk","hcl"などの小文字の略称が付く。

\Lib
    \xxx_vs2012_noRtti
        \release
            libhclCloth.a
            libhkBase.a
    \x64_vs2015
        \debug
        \dev
        \release
            hclCloth.lib
            hkBase.lib

■ファイルヘッダ

// TKBMS v1.0 -----------------------------------------------------
//
// PLATFORM   : ALL
// PRODUCT   : COMMON
// VISIBILITY   : PUBLIC
//
// ------------------------------------------------------TKBMS v1.0

■インクルードガード

#ifndef HKBASE_HKBASE_H
#define HKBASE_HKBASE_H

■型定義

namespaceでは括られていない。

 hkChar
    hkInt8
    hkInt16
    hkInt32
    hkUchar
    hkUint8
    hkUint16
    hkUint32
    hkFloat32
    hkDouble64

名前空間

機能毎に名前空間が定義されてネストはされていない。

namespace hkBaseSystem
{
}

namespace hkMath
{
}

hkBaseSystem::
hkMath::

■class名,struct名

頭にkhなどを付ける。

class HK_EXPORT_COMMON hkVector2f

■関数名

CamelCase

関数名はCamelCaseだけど頭が小文字。

■変数名

■TRACE,ASSERT

HK_ASSERT

PhysX

bullet

Bullet(バレット)とは、Erwin Coumansらによって開発されたオープンソースの物理演算エンジンである。ライセンスはzlib Licenseが適用されている。

なお、開発者のErwin Coumansは、以前Havokに務めており[2]、2003年から2010年までソニー・コンピュータエンタテインメントで勤務したが、その後AMDに移った[3]。2014年5月現在はGoogleで働いている[4]。

■バージョン

2.86.1

■ファイル命名規則

camelCase 頭に"bt"を付ける。 Bullet3の場合は"b3"を付ける。

■フォルダ構成

bullet3-2.86.1\
    build3\
        Android\
        cmake\
    data\
    docs\
    examples\
    Extras\
    src\
        Bullet3Collision\
        Bullet3Common\
        Bullet3Dynamics\
        Bullet3Geometry\
        Bullet3OpenCL\
        Bullet3Serialize\
        BulletCollision\
        BulletDynamics\
        BulletInverseDynamics\
        BulletSoftBody\
        clew\
        LinearMath\
    test\

■libファイル命名規則

■ファイルヘッダ

/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, 
including commercial applications, and to alter it and redistribute it freely, 
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/

■インクルードガード

#ifndef BULLET_COLLISION_COMMON_H
#define BULLET_COLLISION_COMMON_H

■型定義

組み込み型をそのまま使用。

名前空間

一部使用している箇所はあるがライブラリ全体では特に使用していない。

class名,struct名

camelCase 頭に"bt"もしくは"b3"を付ける。

■関数名

camelCase

■変数名

camelCase メンバ変数は"m_"を付ける。

B3_ATTRIBUTE_ALIGNED16(class) b3FixedConstraint : public b3TypedConstraint
{
    b3Vector3 m_pivotInA;
    b3Vector3 m_pivotInB;
    b3Quaternion m_relTargetAB;

public:
    b3FixedConstraint(int  rbA,int rbB, const b3Transform& frameInA,const b3Transform& frameInB);
    
    virtual ~b3FixedConstraint();

    
    virtual void getInfo1 (b3ConstraintInfo1* info,const b3RigidBodyData* bodies);

    virtual void getInfo2 (b3ConstraintInfo2* info, const b3RigidBodyData* bodies);

    virtual void    setParam(int num, b3Scalar value, int axis = -1)
    {
        b3Assert(0);
    }
    virtual b3Scalar getParam(int num, int axis = -1) const
    {
        b3Assert(0);
        return 0.f;
    }

};

■TRACE,ASSERT

ASSERTの定義はあるがなぜかb3Scalar.hに定義されている。 PS3の定義とか関数の一部が書かれているけどこれって大丈夫なの?

#ifdef B3_DEBUG
    #ifdef _MSC_VER
        #include <stdio.h>
        #define b3Assert(x) { if(!(x)){b3Error("Assert "__FILE__ ":%u ("#x")\n", __LINE__);__debugbreak();  }}
    #else//_MSC_VER
        #include <assert.h>
        #define b3Assert assert
    #endif//_MSC_VER
#else
        #define b3Assert(x)
#endif

ODE

ODE(Open Dynamics Engine、オープン・ダイナミクス・エンジン)とは、オープンソース方式で開発されている物理演算エンジンである。BSDライセンスLGPLの両ライセンスが適用されている。

コンポーネントとして動力学演算部分と衝突検出演算部分から構成されている。流体シミュレーション・布シミュレーション・軟体の表現はサポートされていない。

■バージョン

0.13

■ファイル命名規則

snake_case

■フォルダ構成

ode-0.13\
    bindings\
    build\
    drawstuff\
    GIMPACT\
    include\
    libccd\
    m4\
    ode\
    OPCODE\
    ou\
    tests\
    tools\

■libファイル命名規則

■ファイルヘッダ

/*************************************************************************
 *                                                                       *
 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith.       *
 * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
 *                                                                       *
 * This library is free software; you can redistribute it and/or         *
 * modify it under the terms of EITHER:                                  *
 *   (1) The GNU Lesser General Public License as published by the Free  *
 *       Software Foundation; either version 2.1 of the License, or (at  *
 *       your option) any later version. The text of the GNU Lesser      *
 *       General Public License is included with this library in the     *
 *       file LICENSE.TXT.                                               *
 *   (2) The BSD-style license that is included with this library in     *
 *       the file LICENSE-BSD.TXT.                                       *
 *                                                                       *
 * This library is distributed in the hope that it will be useful,       *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
 * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
 *                                                                       *
 *************************************************************************/

■インクルードガード

#ifndef _ODE_TYPEDEFS_H_
#define _ODE_TYPEDEFS_H_

■型定義

/*
 * Internal typedefs to map public types into more convenient private types
 */


typedef dint32 int32;
typedef duint32 uint32;
typedef dint16 int16;
typedef duint16 uint16;
typedef dint8 int8;
typedef duint8 uint8;

名前空間

■class名,struct名

camelCase 頭に小文字の"d"を付ける。

■関数名

camelCase

■変数名

cameCase。 メンバ変数の場合は頭に"_"を付ける。

class dGeom {
  // intentionally undefined, don't use these
  dGeom (dGeom &);
  void operator= (dGeom &);

protected:
  dGeomID _id;

  dGeom()
    { _id = 0; }
public:
  ~dGeom()
    { if (_id) dGeomDestroy (_id); }

  dGeomID id() const
    { return _id; }
  operator dGeomID() const
    { return _id; }

  void destroy() {
    if (_id) dGeomDestroy (_id);
    _id = 0;
  }

  int getClass() const
    { return dGeomGetClass (_id); }

  dSpaceID getSpace() const
    { return dGeomGetSpace (_id); }

  void setData (void *data)
    { dGeomSetData (_id,data); }
  void *getData() const
    { return dGeomGetData (_id); }

  void setBody (dBodyID b)
    { dGeomSetBody (_id,b); }
  dBodyID getBody() const
    { return dGeomGetBody (_id); }

  void setPosition (dReal x, dReal y, dReal z)
    { dGeomSetPosition (_id,x,y,z); }
  const dReal * getPosition() const
    { return dGeomGetPosition (_id); }

  void setRotation (const dMatrix3 R)
    { dGeomSetRotation (_id,R); }
  const dReal * getRotation() const
    { return dGeomGetRotation (_id); }
    
};

■TRACE,ASSERT

/* debugging:
 *   IASSERT  is an internal assertion, i.e. a consistency check. if it fails
 *            we want to know where.
 *   UASSERT  is a user assertion, i.e. if it fails a nice error message
 *            should be printed for the user.
 *   AASSERT  is an arguments assertion, i.e. if it fails "bad argument(s)"
 *            is printed.
 *   DEBUGMSG just prints out a message
 */

#  if defined(__STDC__) && __STDC_VERSION__ >= 199901L
#    define __FUNCTION__ __func__
#  endif
#ifndef dNODEBUG
#  ifdef __GNUC__
#    define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
      "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); } }
#    define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
      msg " in %s()", __FUNCTION__); } }
#    define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT,               \
  msg " in %s() [%s:%u]", __FUNCTION__,__FILE__,__LINE__); }
#  else // not __GNUC__
#    define dIASSERT(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
      "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); } }
#    define dUASSERT(a,msg) { if (!(a)) { dDebug (d_ERR_UASSERT, \
      msg " (%s:%u)", __FILE__,__LINE__); } }
#    define dDEBUGMSG(msg) { dMessage (d_ERR_UASSERT, \
      msg " (%s:%u)", __FILE__,__LINE__); }
#  endif
#  define dIVERIFY(a) dIASSERT(a)
#else
#  define dIASSERT(a) ((void)0)
#  define dUASSERT(a,msg) ((void)0)
#  define dDEBUGMSG(msg) ((void)0)
#  define dIVERIFY(a) ((void)(a))
#endif

#  ifdef __GNUC__
#    define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
      "assertion \"" #a "\" failed in %s() [%s:%u]",__FUNCTION__,__FILE__,__LINE__); *(int *)0 = 0; } }
#  else // not __GNUC__
#    define dICHECK(a) { if (!(a)) { dDebug (d_ERR_IASSERT, \
      "assertion \"" #a "\" failed in %s:%u",__FILE__,__LINE__); *(int *)0 = 0; } }
#  endif

CRI(ADX)

サウンド関連のミドルウェア。 基本はC言語で書かれている模様。

■バージョン

2.09

■ファイル命名規則

基本はsnake_caseで一部CamelCase。 頭に必ず"cri_"、"Cri"が付く。 Cベースがsnake_caseでC++ベースがCamelCase。

cri_atom.h cri_framework.h CriSmpFsUtility.h

文字コード

UTF8(BOM) 日本が含まれているためにUTF8(BOM)になっている。

■フォルダ構成

\cri
    \pc
        \include
        \libs
            \x64
            \x86
    \xxx

■libファイル命名規則

snake_case デバッグビルド版は最後に大文字の"D"が付く。

\pc
    \libs
        \x64
            cri_atom_pcx64.lib
            cri_atom_pcx64D.lib
\xxx
    \libs
        libcri_atom_xxx.a
        libcri_atom_xxxD.a    

■ファイルヘッダ

/****************************************************************************
 *
 * CRI Middleware SDK
 *
 * Copyright (c) 2009-2015 CRI Middleware Co., Ltd.
 *
 * Library  : CRI Framework
 * Module   : Library User's Header
 * File     : cri_framework.h
 *
 ****************************************************************************/

■インクルードガード

/* 多重定義防止                   */
/* Prevention of redefinition  */
#ifndef CRI_INCL_CRI_ATOM_H
#define CRI_INCL_CRI_ATOM_H

■型定義

頭に"Cri"が付く。 namespaceなどでは括られていない。

CriUint8 CriSint8 CriUint16 CriSint16 CriFloat16 CriFloat32 CriFlott64 CriBool CriChar8

#if !defined(_TYPEDEF_CriUint8)
#define _TYPEDEF_CriUint8
typedef unsigned char           CriUint8;       /* 符号なし1バイト整数 */
#endif

#if !defined(_TYPEDEF_CriSint8)
#define _TYPEDEF_CriSint8
typedef signed char             CriSint8;       /* 符号つき1バイト整数 */
#endif

名前空間

無し。

■class名,struct名

typedef struct CriAtomConfigTag {
};

■関数名

■変数名

snake_case

 CriUint32 version;
    CriSint32 max_players;

■TRACE,ASSERT

コンパイル時ASSERTの定義はある。

#define XPT_STATIC_ASSERT(cond) void xpt_static_assert_dummy_function(void* xpt_static_assert_array[(cond)?1:-1])

BISHAMON

エフェクトエンジン関連のミドルウェア。 旧名はBlendMagic。

■バージョン

2.1.0

■ファイル命名規則

snake_case。 社名のMatchLockの略称と思われる"ml"が頭に付く。

ml.h ml_def.h ml_color.h

"bm"で始まるものある。 BlendMagic、BISHAMONの略称と思われる。

文字コード

UTF8(BOM)

■フォルダ構成

\bishamon
    \xxx
        \include
            \ml
                \bm
                \debug
                \gxd
                \math
                \mp
                \pp
                \type
                \utility
        \libs

■libファイル命名規則

snake_case。

\bishamon \xxx \libs libml_xxx.a libml_xxxd.a

■ファイルヘッダ

/**
 * ml/ml_def.h
 */

■インクルードガード

#ifndef MATCHLOCK_ML_DEF_H
#define MATCHLOCK_ML_DEF_H

■型定義

namespace ml
{
    typedef signed   char  si8;
    typedef unsigned char  ui8;
    typedef signed   short si16;
    typedef unsigned short ui16;

    typedef float  f32;
    typedef double f64;

    typedef char char_t;
}

名前空間

namespace ml
{

namespace debug
{
}

namespace math
{
}

}

■class名,struct名

■関数名

■変数名

snake_case。 classのメンバ変数は後ろに"_"を付ける。

■TRACE,ASSERT

#define ML_DEBUG_TEXT(...)   ((const char*)0)
#define ML_DEBUG_REPORT(...) ((void)0)
#define ML_DEBUG_OUTPUT(_)   ((void)0)
#define  ML_ASSERT(cond) 
#define ML_ASSERT_MESSAGE(cond, ...)
#define  ML_STATIC_ASSERT(cond)                              \

steam

■バージョン

■ファイル命名規則

■フォルダ構成

■libファイル命名規則

■ファイルヘッダ

■インクルードガード

■型定義

名前空間

■class名,struct名

■関数名

■変数名

■TRACE,ASSERT

cocos2d-x

■バージョン

■ファイル命名規則

■フォルダ構成

■libファイル命名規則

■ファイルヘッダ

■インクルードガード

■型定義

名前空間

■class名,struct名

■関数名

■変数名

■TRACE,ASSERT

PhyreEngine

SIE提供のPS4PS3PSVita、PC用のクロスプラットフォームゲームエンジン