From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/move__primitive_8h-source.html | 478 ++++++++++++++++++++++++ 1 file changed, 478 insertions(+) create mode 100644 docs/doxygen/nel/move__primitive_8h-source.html (limited to 'docs/doxygen/nel/move__primitive_8h-source.html') diff --git a/docs/doxygen/nel/move__primitive_8h-source.html b/docs/doxygen/nel/move__primitive_8h-source.html new file mode 100644 index 00000000..f935b692 --- /dev/null +++ b/docs/doxygen/nel/move__primitive_8h-source.html @@ -0,0 +1,478 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

move_primitive.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_MOVE_PRIMITIVE_H
+00027 #define NL_MOVE_PRIMITIVE_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/vector.h"
+00031 
+00032 #include "nel/pacs/u_move_primitive.h"
+00033 
+00034 #include "pacs/move_container.h"
+00035 #include "pacs/primitive_world_image.h"
+00036 #include "pacs/global_retriever.h"
+00037 
+00038 #define NELPACS_DIST_BACK 0.01
+00039 
+00040 namespace NLPACS 
+00041 {
+00042 
+00052 class CMovePrimitive: public UMovePrimitive
+00053 {
+00054 private:
+00055         friend class CMoveContainer;
+00056 
+00057         // Some flags
+00058         enum TStaticFlags
+00059         {
+00060                 // Mask for the primitive type
+00061                 PrimitiveMask   =0x000f,
+00062 
+00063                 // Mask for the primitive type
+00064                 ReactionMask    =0x00f0,
+00065 
+00066                 // Mask for the trigger type
+00067                 TriggerMask             =0x0f00,
+00068 
+00069                 // Obstacle flag. This flag tells that this object is an obstacle for others objects.
+00070                 ObstacleFlag    =0x1000,
+00071 
+00072                 // Ghost flag. This flag tells that this object is a ghost object or not.
+00073                 NonCollisionableFlag    =0x2000,
+00074                 
+00076                 DontSnapToGroundFlag = 0x4000,
+00077 
+00078                 // Force the size to uint16.
+00079                 ForceSize               =0xffff
+00080         };
+00081 
+00082 public:
+00083 
+00085         CMovePrimitive (CMoveContainer* container, uint8 firstWorldImage, uint8 numWorldImage);
+00086 
+00088         virtual ~CMovePrimitive ();
+00089         //
+00090         virtual void    setDontSnapToGround(bool dont)
+00091         {
+00092                 if (dont) _StaticFlags |= DontSnapToGroundFlag;
+00093                 else _StaticFlags &= ~DontSnapToGroundFlag;
+00094         }
+00095         //
+00096         bool    getDontSnapToGround() const 
+00097         {
+00098                 return (_StaticFlags & DontSnapToGroundFlag) != 0;
+00099         }
+00100         // Return true if this primitive is noncollisionable
+00101         bool isNonCollisionable () const
+00102         {
+00103                 return (_StaticFlags&NonCollisionableFlag)!=0;
+00104         }
+00105 
+00106         // Set noncollisionable
+00107         void setNonCollisionable (bool nonCollisionable)
+00108         {
+00109                 if (nonCollisionable)
+00110                         _StaticFlags|=NonCollisionableFlag;
+00111                 else
+00112                         _StaticFlags&=~NonCollisionableFlag;
+00113         }
+00114 
+00115         // Get the nieme world image
+00116         CPrimitiveWorldImage            *getWorldImage (uint i) const
+00117         {
+00118                 // Checks this primitive belong of the requested world image.
+00119                 nlassert ((i>=(uint)_FirstWorldImage)&&(i<(uint)_FirstWorldImage+(uint)_NumWorldImage));
+00120 
+00121                 // Return the good one
+00122                 return _WorldImages[i-_FirstWorldImage];
+00123         }
+00124 
+00125         // is the primitive inserted in the world image
+00126         bool isInserted (uint i) const
+00127         {
+00128                 // Checks
+00129                 if ((i>=(uint)_FirstWorldImage)&&(i<(uint)_FirstWorldImage+(uint)_NumWorldImage))
+00130                 {
+00131                         // Get world image
+00132                         return getWorldImage (i)->isInWorldImageFlag ();
+00133                 }
+00134                 else
+00135                         return false;
+00136         }
+00137 
+00138         virtual uint8                           getFirstWorldImageV () const;
+00139         virtual uint8                           getNumWorldImageV () const;
+00140 
+00141         // Get first world image used
+00142         uint8   getFirstWorldImage () const
+00143         {
+00144                 return _FirstWorldImage;
+00145         }
+00146 
+00147         // Get count of world image used
+00148         uint8   getNumWorldImage () const
+00149         {
+00150                 return _NumWorldImage;
+00151         }
+00152 
+00153         // Dirt positions of the primitive in all the world images
+00154         void    dirtAllPos ()
+00155         {
+00156                 for (uint i=0; i<_NumWorldImage; i++)
+00157                 {
+00158                         // Get world image and check if it exist
+00159                         CPrimitiveWorldImage    *worldImage=_WorldImages[i];
+00160 
+00161                         // Dirt its pos
+00162                         worldImage->dirtPos (_Container, this, i+_FirstWorldImage);
+00163                 }
+00164         }
+00165 
+00171         void    setPrimitiveType (TType type)
+00172         {
+00173                 // New position
+00174                 _StaticFlags&=~(uint32)PrimitiveMask;
+00175                 _StaticFlags|=type;
+00176         }
+00177 
+00183         void    setReactionType (TReaction type)
+00184         {
+00185                 // New position
+00186                 _StaticFlags&=~(uint32)ReactionMask;
+00187                 _StaticFlags|=type;
+00188         }
+00189 
+00195         void    setTriggerType (TTrigger type)
+00196         {
+00197                 // New position
+00198                 _StaticFlags&=~(uint32)TriggerMask;
+00199                 _StaticFlags|=type;
+00200         }
+00201 
+00207         void    setCollisionMask (TCollisionMask mask)
+00208         {
+00209                 _CollisionMask=mask;
+00210         }
+00211 
+00217         void    setOcclusionMask (TCollisionMask mask)
+00218         {
+00219                 _OcclusionMask=mask;
+00220         }
+00221 
+00227         void    setObstacle (bool obstacle)
+00228         {
+00229                 // New flag
+00230                 if (obstacle)
+00231                         _StaticFlags|=ObstacleFlag;
+00232                 else
+00233                         _StaticFlags&=~(uint32)ObstacleFlag;
+00234         }
+00235 
+00242         void    setSize (float width, float depth)
+00243         {
+00244                 // Checks
+00245                 nlassert ((((uint32)_StaticFlags)&PrimitiveMask)==_2DOrientedBox);
+00246 
+00247                 // New position
+00248                 _Length[0]=width;
+00249                 _Length[1]=depth;
+00250         }
+00251 
+00257         void    setHeight (float height)
+00258         {
+00259                 // New size
+00260                 _Height=height;
+00261         }
+00262 
+00268         void    setRadius (float radius)
+00269         {
+00270                 // Checks
+00271                 nlassert ((((uint32)_StaticFlags)&PrimitiveMask)==_2DOrientedCylinder);
+00272 
+00273                 // New position
+00274                 _Length[0]=radius;
+00275         }
+00276 
+00278         TType   getPrimitiveTypeInternal () const
+00279         {
+00280                 // New position
+00281                 return (TType)(_StaticFlags&(uint32)PrimitiveMask);
+00282         }
+00283 
+00285         TReaction       getReactionTypeInternal () const
+00286         {
+00287                 // New position
+00288                 return (TReaction)(_StaticFlags&(uint32)ReactionMask);
+00289         }
+00290 
+00292         TTrigger        getTriggerTypeInternal () const
+00293         {
+00294                 // New position
+00295                 return (TTrigger)(_StaticFlags&(uint32)TriggerMask);
+00296         }
+00297 
+00299         TCollisionMask  getCollisionMaskInternal () const
+00300         {
+00301                 // New position
+00302                 return _CollisionMask;
+00303         }
+00304 
+00306         TCollisionMask  getOcclusionMaskInternal () const
+00307         {
+00308                 // New position
+00309                 return _OcclusionMask;
+00310         }
+00311 
+00313         float getAttenuation() const
+00314         {
+00315                 return _Attenuation;
+00316         }
+00317 
+00319         float getLength (uint where) const
+00320         {
+00321                 return _Length[where];
+00322         }
+00323 
+00325         float getHeightInternal () const
+00326         {
+00327                 return _Height;
+00328         }
+00329 
+00331         float getRadiusInternal () const
+00332         {
+00333                 return _Length[0];
+00334         }
+00335 
+00337         bool isObstacle () const
+00338         {
+00339                 return (_StaticFlags&ObstacleFlag)!=0;
+00340         }
+00341 
+00343         bool    isCollisionable() const
+00344         {
+00345                 return !isNonCollisionable();
+00346         }
+00347 
+00349         void addCollisionOTInfo (CCollisionOTInfo *info)
+00350         {
+00351                 // Link to the list
+00352                 info->primitiveLink (this, _RootOTInfo);
+00353                 _RootOTInfo=info;
+00354         }
+00355 
+00357         void removeCollisionOTInfo (CCollisionOTInfo *toRemove);
+00358 
+00360         void removeCollisionOTInfo ();
+00361 
+00363         void checkSortedList ();
+00364 
+00366         bool isTriggered (CMovePrimitive& second, bool enter, bool exit);
+00367 
+00369 
+00370         void                                    setAbsorbtion (float attenuation);
+00371         void                                    setOrientation (double rot, uint8 worldImage);
+00372         void                                    setGlobalPosition (const NLMISC::CVectorD& pos, uint8 worldImage);
+00373         void                                    setGlobalPosition (const UGlobalPosition& pos, uint8 worldImage);
+00374         void                                    move (const NLMISC::CVectorD& speed, uint8 worldImage);
+00375         NLMISC::CVectorD                getFinalPosition (uint8 worldImage)  const;
+00376         const NLMISC::CVectorD& getSpeed (uint8 worldImage) const;
+00377         void                                    insertInWorldImage (uint8 worldImage);
+00378         void                                    removeFromWorldImage (uint8 worldImage);
+00379         TType                                   getPrimitiveType () const;
+00380         TReaction                               getReactionType () const;
+00381         TTrigger                                getTriggerType () const;
+00382         TCollisionMask                  getCollisionMask () const;
+00383         TCollisionMask                  getOcclusionMask () const;
+00384         bool                                    getObstacle () const;
+00385         float                                   getAbsorbtion () const;
+00386         void                                    getSize (float& width, float& depth) const;
+00387         float                                   getHeight () const;
+00388         float                                   getRadius () const;
+00389         double                                  getOrientation (uint8 worldImage) const;
+00390         void                                    getGlobalPosition (UGlobalPosition& pos, uint8 worldImage) const;
+00391 
+00392         // Test time. Return true if tetst can be perform, false if too many test have been computed for this primitive
+00393         bool checkTestTime (uint32 testTime, uint32 maxTestIteration)
+00394         {
+00395                 // Already checked for this test time ?
+00396                 if (testTime!=_LastTestTime)
+00397                 {
+00398                         // First time this primitive is visited at this test
+00399                         _LastTestTime=testTime;
+00400 
+00401                         // Test counter
+00402                         _IterationCount=maxTestIteration;
+00403                 }
+00404                 else
+00405                 {
+00406                         // Too many test this primitive ?
+00407                         if (_IterationCount<=0)
+00408                         {
+00409 //                              nlwarning("in checkTestTime(): Get to the max iteration count");
+00410                                 return false;
+00411                         }
+00412                         else
+00413                                 _IterationCount--;
+00414                 }
+00415                 // Ok, test can be performed
+00416                 return true;
+00417         }
+00418 
+00419         // *** Get mass
+00420         
+00421         float getMass () const
+00422         {
+00423                 // Box ?
+00424                 if ( (_StaticFlags&PrimitiveMask) == _2DOrientedBox )
+00425                         return _Length[0]*_Length[1]*_Height;
+00426                 // Cylinder ?
+00427                 else
+00428                 {
+00429                         nlassert ( (_StaticFlags&PrimitiveMask) == _2DOrientedCylinder );
+00430                         return _Length[0]*(float)NLMISC::Pi*_Height;
+00431                 }
+00432         }
+00433 
+00434         // *** Primitive over primitive
+00435 
+00436 private:
+00437         // The length of the 4 edges. The first is the width, the second is the depth
+00438         // For cylinder, the first is the radius
+00439         float                           _Length[2];
+00440 
+00441         // This is the height of the box or of the cylinder.
+00442         float                           _Height;
+00443 
+00444         // Attenuation 
+00445         float                           _Attenuation;
+00446 
+00447         // Flags
+00448         uint16                          _StaticFlags;
+00449 
+00450         // Num world images
+00451         uint8                           _NumWorldImage;
+00452 
+00453         // First world images
+00454         uint8                           _FirstWorldImage;
+00455 
+00456         // Occlusion mask
+00457         TCollisionMask          _OcclusionMask;
+00458 
+00459         // Collision mask
+00460         TCollisionMask          _CollisionMask;
+00461 
+00462         // Container of this primitive
+00463         CMoveContainer          *_Container;
+00464 
+00465         // List of time ordered table element using this primitive
+00466         CCollisionOTInfo        *_RootOTInfo;
+00467 
+00468         // Pointer table of world images for this primitive
+00469         CPrimitiveWorldImage    **_WorldImages;
+00470 
+00471         // Last primitive test time
+00472         uint32                          _LastTestTime;
+00473 
+00474         // Iteration count
+00475         sint32                          _IterationCount;
+00476 };
+00477 
+00478 } // NLPACS
+00479 
+00480 #include "pacs/move_container_inline.h"
+00481 
+00482 #endif // NL_MOVE_PRIMITIVE_H
+00483 
+00484 /* End of move_primitive.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1