Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Amir_r_KB

  • Rank

Personal Information

  • Interests
  1. Amir_r_KB

    Retention In Physics Simulations

    Sorry i wasn't clear with what i meant by challenges. I meant structural not maths. ie: Will i run into problems if i don't retain and just loop over the main entities? what would be the tradeoffs? Some i can think of are probably the data locality when dealing with spatial partitioning. But then even O(n^2) might not be a big problem with my game. Can you give an example?
  2. Hi everyone, I wanna know the thoughts of people who have implemented or have experience with physics sims and/or collision detection routines, on the retention and data representation part of the equation. I've recently poked PhysX to see how it can be integrated to my 3D game, but immediately realized that i absolutely hate the way it wants me to keep all state in sync, and it gets ugly very quickly, not to mention all the copying and conversions that should happen every frame. All because it keeps an internal representation called "Actors" to make everything magically work after simulate(); . I know this gives the API more control over its internal simulation and optimization, but it becomes trouble for the app that's using it. As if the API was made with the expectation that the user only loads a scene once and never wants to inject changes into it... Now I've decided to make my own collision detection/physics without use of any retention, and just use the entity state as the input to test functions. But Considering that i haven't implemented any physics sim yet, i can't foresee the requirements and challenges, so i don't know.. even retention might become necessary. and my game doesn't depend much on physics nor does it use any substantial number of rigid bodies. for now i'm just thinking about simple collision detection. Any thoughts?
  3. Mainly out of curiosity and also the verbosity of STL, the syntax looks awful to me. Although i'm aware of the downsides of making a new one. Thanks a ton! that was the issue. I didn't even know about placement new! True i'll change them. I may be wrong but for now i won't use any exceptions anywhere, to keep things cleaner and avoid their overhead.
  4. Hi, I just implemented my first resizable container ( std::vector ) and it broke on the first attempt lol! Heap corruption is caught when the assignment operator attempts to free() old data, and it works fine without free() , which of course is a leak. Here's the use case : ( simplified from a recursive function ) typedef struct Widget { Vec3 pos; float width; float height; List<Widget> children; }; List<Widget> list ; Widget widget = {}; widget.children.add (widget); widget.children.add (widget); // Heap corruption when free() is called in assignment operator=() Definition : template <typename T> struct List { T* start = 0; u64 capacity = 0; u64 size = 0; inline List ( ) {}; inline List ( u32 count ); inline List ( const List<T>& other ) ; inline ~List ( ); inline void add ( T element ); inline void reserve ( u32 count ); inline void clear (); inline T& operator[] (u64 x) { return start[x]; } inline List<T>& operator=( List<T>& other ); }; template <typename T> List<T>::List ( u32 count ) { u32 len = sizeof(T) * count; start = (T*) malloc ( len ); size = 0; capacity = len; }; template <typename T> List<T>::List ( const List<T>& other ) { u64 len = other.size * sizeof(T) ; if ( other.size ) { start = (T*) malloc ( len ); for ( int i=0; i < other.size; i++) { start[i] = other.start[i]; } } size = other.size; capacity = len; } template <typename T> List<T>::~List ( ) { if ( start ) free ( start ); }; template <typename T> List<T>& List<T>::operator=( List<T>& other ) { u64 len = other.size * sizeof(T) ; if ( other.size ) { if ( start ) free ( start ); // Corruption exception from here start = (T*) malloc ( len ); for ( int i=0; i < other.size; i++) { start[i] = other[i]; } } size = other.size; capacity = len; return *this; } template <typename T> inline void List<T>::add ( T element ) { if ( !start ) { reserve ( 1 ); start[size] = element; size++; return; } if ( size >= ( capacity / sizeof(T) ) ) { reserve ( size + 1 ); } start[size] = element; size++; }; template <typename T> inline void List<T>::reserve ( u32 count ) { if ( count == 0 ) { clear(); return; } if ( count == size ) { return; } T* old = start; u64 len = sizeof(T) * count * 2; start = (T*) malloc ( len ); for ( int i=0; i < size; i++) { start[i] = old[i]; } capacity = len; if ( old ) free ( old ); } template <typename T> inline void List<T>::clear () { if ( start ) free ( start ); size = 0; capacity = 0; }; For some reason it sometimes works without any exceptions being thrown..
  5. Amir_r_KB

    Handling World Transformations

    Thanks for help. I thought the first way might cause problems for open world games, but structured buffers can probably do the trick.
  6. Hi everyone, I think my question boils down to "How do i feed shaders?" I was wondering what are the good strategies to store mesh transformation data [World matrices] to then be used in the shader for transforming vertices (performance being the priority ). And i'm talking about a game scenario where there are quite a lot of both moving entities, and static ones, that aren't repeated enough to be worth instanced drawing. So far i've only tried these naive methods : DX11 : - Store transforms of ALL entities in a constant buffer ( and give the entity an index to the buffer for later modification ) - Or store ONE transform in a constant buffer, and change it to the entity's transform before each drawcall. Vulkan : - Use Push Constants to send entity's transform to the shader before each drawcall, and maybe use a separate Device_local uniform buffer for static entities? Same question applies to lights. Any suggestions?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!