Jump to content

  • Log In with Google      Sign In   
  • Create Account


Zaoshi Kaba

Member Since 04 Nov 2012
Offline Last Active Today, 05:03 AM

#5181103 c++ Performance boost needed

Posted by Zaoshi Kaba on 17 September 2014 - 02:12 PM

  1. Yes, operator[] is a little slower, especially if you have exceptions/etc turned on; it checks whether range is valid, etc. However your loop isn't big enough to make a any noticeable difference.
  2. std::clock() has horrible accuracy. Even if there is performance difference you won't notice until it's huge or it'll round wrong way giving invalid data, ex. execution time can increase by 1% by rounding will change from 16ms to 32ms. Pointers aren't "faster" or "slower", however when misused they definitely can be slower because of cache misses.
  3. I have suspicions that your handConflictsBoard() function passes values instead of references, thus copying a lot of data when it's not necessary which is likely source of your slowdown.

​If you want to make your code faster first you need to figure which part is the slowest and then see how you can improve it. Optimizing random code parts isn't likely to give significant difference.




#5180215 Preprocessor query

Posted by Zaoshi Kaba on 14 September 2014 - 04:45 AM

Won't this turn __COUNTER__(a) into a string instead of calling macro and turning result into a string?

 

There's some command line parameter to output preprocessed file, that way you can see result you're getting instead of playing guessing game.




#5179813 Which algorithm is more efficient for visibility culling? BSP or OCTree?

Posted by Zaoshi Kaba on 12 September 2014 - 02:56 AM


brute force, just iterate over the set of renderables and cull them against the view frustum. Even better, pack the bounding boxes with handles back to the owner into an array and iterate that much more cache efficient, minimal branching (in fact, you can delay branching till the end in most cases).

 

To backup Washu I can say I've done thesis on view frustum culling and bruteforce method culls 340,000 AABBs in 1 millisecond. If this isn't sufficient you might have different problems.




#5177680 For-loop-insanity

Posted by Zaoshi Kaba on 02 September 2014 - 10:51 AM


Since we are trying to come up with new, obscure, and complicated ways for counting up, how about this

Somehow I can see Java programmer actually doing this.




#5177206 Font Rendering Woes (FreeType)

Posted by Zaoshi Kaba on 31 August 2014 - 08:19 AM

Are you sure this is not .jpg artifact? I'm not sure how good quality is on those.




#5175284 DirectX with or without Visual Studio 2013

Posted by Zaoshi Kaba on 21 August 2014 - 08:52 AM

D3DX is Direct3D Extension, which included texture loading and other things, it's not DirectX API. It has been removed in some version and you have to implement that yourself.

I think DirectX Tool Kit implements most things D3DX used to have.




#5174257 Thesis idea: offline collision detection

Posted by Zaoshi Kaba on 17 August 2014 - 07:13 AM

I don't feel this is possible.

You'd need 2 transformation matrices per situation. Even if you do accuracy of 1 degree you get 360 * 360 * 360 = 46,656,000 combinations. Add to that matrix size of 16 * 4 * 2 = 128 and it's suddenly 6 gigabytes of data and you still haven't taken into account translation or scaling.

 

Unless I have wrong idea...




#5172366 How to make 3D Character move to a specific point

Posted by Zaoshi Kaba on 08 August 2014 - 04:28 PM

You should figure vectors; it's along the lines of:

difference = destination - position;
direction = normalize(difference);
movement = direction * move_speed;



#5172351 DXGI leak warnings

Posted by Zaoshi Kaba on 08 August 2014 - 03:24 PM

Refcount of 0 means object has been released but not destroyed yet. It'll happen sometime later, don't worry about these.

IntRef of >= 1 means object is bound (PSSetShader, etc), shouldn't worry about these either, they'll get destroyed once possible.

 

Though you have some objects with massive amount references:

Live ID3D11RasterizerState at 0x009E872C, Refcount: 2337

Live Object at 0x00BCC7BC, Refcount: 448.

 

Are you sure you don't have regular memory leaks leading to objects not being destroyed?

Do you destroy all ComPtr before releasing device?




#5172130 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 03:03 PM

That's weird. Could you try to replace your main / WinMain method with this code just to test whether you get correct results with minimal code?

And of course you'll need to fix Bullet paths.

#include <iostream>
using std::cout;
#include <DirectXMath.h>
using DirectX::XMFLOAT3;
#include "../Bullet Physics/btBulletCollisionCommon.h"
#include "../Bullet Physics/btBulletDynamicsCommon.h"
#pragma comment(lib, "../x64/Debug/Bullet Physics.lib")

btRigidBody* addRigidSpehere(float rad, XMFLOAT3 position)
{
	btTransform t;
	t.setIdentity();
	t.setOrigin(btVector3(position.x, position.y, position.z));

	btSphereShape* sphere = new btSphereShape(rad);

	//calculate inertia
	btVector3 inertia(0.0, 0.0, 0.0);
	sphere->calculateLocalInertia(1.0, inertia);

	btMotionState* motionState = new btDefaultMotionState(t);
	btRigidBody::btRigidBodyConstructionInfo info(1.0, motionState, sphere, inertia);
	btRigidBody* sphereBody = new btRigidBody(info);

	return sphereBody;
}

void main() {
	auto bulletConfiguration = new btDefaultCollisionConfiguration();
	auto bulletDispatcher = new btCollisionDispatcher(bulletConfiguration);
	auto bulletBroadPhaseInterface = new btDbvtBroadphase();
	auto bulletSolver = new btSequentialImpulseConstraintSolver();

	auto bulletWorld = new btDiscreteDynamicsWorld(bulletDispatcher, bulletBroadPhaseInterface, bulletSolver, bulletConfiguration);
	bulletWorld->setGravity(btVector3(0, -10, 0));

	btTransform t;
	t.setIdentity();
	t.setOrigin(btVector3(0, 0, 0));

	btStaticPlaneShape* plane = new btStaticPlaneShape(btVector3(0, 1, 0), 0.0);
	btMotionState* motionStatePlane = new btDefaultMotionState(t);
	btRigidBody::btRigidBodyConstructionInfo info(0.0, motionStatePlane, plane);
	btRigidBody* planeBody = new btRigidBody(info);

	bulletWorld->addRigidBody(planeBody);

	auto sphere = addRigidSpehere(1, XMFLOAT3(0, 3, 0));
	bulletWorld->addRigidBody(sphere);

	while(1) {
		bulletWorld->stepSimulation(1.0 / 60.0);
		cout << sphere->getWorldTransform().getOrigin().getX() << ", ";
		cout << sphere->getWorldTransform().getOrigin().getY() << ", ";
		cout << sphere->getWorldTransform().getOrigin().getZ() << "\n";
	}
}



#5172100 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 01:13 PM

I probably have 2.82 too. Are you sure you're not modifying it somewhere accidently; like force, velocity, or position?

I used this loop and a debugger to inspect values:

	while(1) {
		bulletWorld->stepSimulation(1.0 / 60.0);
		OutputDebugString(to_wstring(sphere->getWorldTransform().getOrigin().getX()).c_str());
		OutputDebugString(L", ");
		OutputDebugString(to_wstring(sphere->getWorldTransform().getOrigin().getY()).c_str());
		OutputDebugString(L", ");
		OutputDebugString(to_wstring(sphere->getWorldTransform().getOrigin().getZ()).c_str());
		OutputDebugString(L"\n");
	}

First few values are 3.0 and lower, but eventually it stops at 0.000000, 1.000000, 0.000000 and just spams that.

(seems debugger and outputting to debug console gives different numbers; rounding?).




#5172090 Inertia Causing Extremely odd effects.

Posted by Zaoshi Kaba on 07 August 2014 - 12:27 PM

I am unable to reproduce this problem. I copy pasted your code and sphere stops at position {0.000000000, 0.999999821, 0.000000000, 0.000000000}.




#5171808 Interrupt handling very slow

Posted by Zaoshi Kaba on 06 August 2014 - 03:03 AM

I noticed a lot of people make mistake of using if(PeekMessage(&message, 0, 0, 0, PM_REMOVE)) instead of while(...) inside game loop, this might be source of the problem.




#5170975 Isn't "delete" so pesky to type? Wish there was a better way?

Posted by Zaoshi Kaba on 01 August 2014 - 03:54 PM

I am disturbed by how legit this thread sounds.




#5170613 [Questions] First RenderLoop with Fixed Time-Step and Animations ...

Posted by Zaoshi Kaba on 31 July 2014 - 09:23 AM


Basically I want to make sure my RenderLoop runs properly

Define properly. Most would say you need to use fixed time step to have proper game loop. There's a link in your code, and if that isn't sufficient I can also suggest this article.

 


running at the Time I've intended them to run independent of the FPS

You just measure time since last frame and move everything by that much. For example, your character moves 2 m/s, so you multiply that by time elapsed in seconds and you get distance character moved since last frame. This will happen in your Update() function.

 

However, if you are using fixed time step then elapsed time in Update() function will be constant, ex. 0.03(3) seconds if you want 30 UPS (updates per second). Then your Render() function interpolates between last position and current position (it's explained in the article I linked earlier).






PARTNERS