x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

64 Bit UE how much bytes using memory alignment ?

Hi,

I added thirdparty library as a plugin in unreal (Bullet Physics. Not a replacement of physx just for some functions). But when i use my working code in unreal it gives "unable to read memory" errors.

When i debug it i see unable to read memory errors on variables, actors ...

So i am thinking maybe Bullets memory management collides with unreals. Bullet uses 16byte alignment. Is this can be source of problem ? Maybe if i tell bullet use same alignment as unreal this can be solution to this problem ?

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "SharpSurgeon.h"
 #include "TestActor.h"
 
 #include "btBulletDynamicsCommon.h"
 #include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
 #include "BulletSoftBody/btDefaultSoftBodySolver.h"
 #include "BulletSoftBody/btSoftBodyHelpers.h"
 #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
 
 struct bulletObject {
     int id;
     float r, g, b;
     bool hit;
     btRigidBody* body;
     bulletObject(btRigidBody* b, int i, float r0, float g0, float b0) : body(b), id(i), r(r0), g(g0), b(b0), hit(false) {}
 };
 
 
 btSoftRigidDynamicsWorld* world;
 btDispatcher* dispatcher;
 btCollisionConfiguration* collisionConfig;
 btBroadphaseInterface* broadphase;
 btConstraintSolver* solver;
 btSoftBodySolver* softbodySolver;
 TArray<bulletObject*> bodies;
 btSoftBody* softBody;
 btTransform t;
 btMotionState* motion;
 btStaticPlaneShape* plane;
 btRigidBody* body;
 btRigidBody::btRigidBodyConstructionInfo info(0.0, motion, plane);
 
 
 // Sets default values
 ATestActor::ATestActor()
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 }
 
 // Called when the game starts or when spawned
 void ATestActor::BeginPlay()
 {
     Super::BeginPlay();
     collisionConfig = new btSoftBodyRigidBodyCollisionConfiguration();
     dispatcher = new btCollisionDispatcher(collisionConfig);
     broadphase = new btDbvtBroadphase();
     solver = new btSequentialImpulseConstraintSolver();
     softbodySolver = new btDefaultSoftBodySolver();
     world = new btSoftRigidDynamicsWorld(dispatcher, broadphase, solver, collisionConfig, softbodySolver);
     world->setGravity(btVector3(0, -10, 0));
 
     t.setIdentity();
     t.setOrigin(btVector3(0, 0, 0));
     plane = new btStaticPlaneShape(btVector3(0, 1, 0), 0);
     motion = new btDefaultMotionState(t);
 
     body = new btRigidBody(info);
     world->addRigidBody(body);
     bodies.Add(new bulletObject(body, 4, 0.8, 0.8, 0.8));
     body->setUserPointer(bodies[bodies.Num() - 1]);
 
     float s = 4;
     float h = 20;
 
     softBody = btSoftBodyHelpers::CreateEllipsoid(world->getWorldInfo(),
         btVector3(10, 10, 10), btVector3(2, 2, 2), 1000);
     softBody->m_cfg.viterations = 50;
     softBody->m_cfg.piterations = 50;
     softBody->m_cfg.kPR = 1000;
     softBody->setTotalMass(3.0);
     softBody->setMass(0, 0);
     world->addSoftBody(softBody);
 
 }
 
 // Called every frame
 void ATestActor::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
     world->stepSimulation(DeltaTime);
 }
 
 

Best, Korcan

Product Version: UE 4.12
Tags:
more ▼

asked Jun 21 '16 at 03:57 PM in C++ Programming

avatar image

Korcan
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question