Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "Headers/Character.h"
#include "Graphs/Headers/SceneGraphNode.h"
#include "Core/Math/Headers/Transform.h"
#include "Hardware/Video/Headers/GFXDevice.h"

namespace Divide {

Character::Character(CharacterType type, SceneGraphNode* const node) : Unit(Unit::UNIT_TYPE_CHARACTER, node),
                                                                       _type(type)
{

	_positionDirty = false;
	_velocityDirty = false;
    setRelativeLookingDirection(WORLD_Z_NEG_AXIS);
    _newVelocity.reset();
    _curVelocity.reset();
    PhysicsComponent* const transform = node->getComponent<PhysicsComponent>();
    if(node && transform){
        _newPosition.set(transform->getPosition());
        _oldPosition.set(_newPosition);
        _curPosition.set(_oldPosition);
        _positionDirty = true;
    }
}

Character::~Character()
{
}

void Character::update(const U64 deltaTime) {
    if(_positionDirty){
        _curPosition.lerp(_newPosition, getUsToSec(deltaTime));
        _positionDirty = false;
    }

    if(_velocityDirty && _newVelocity.length() > 0.0f){
        _newVelocity.y = 0.0f;
        _newVelocity.z *= -1.0f;
        _newVelocity.normalize();
        _curVelocity.lerp(_newVelocity, getUsToSec(deltaTime));
        _velocityDirty = false;
    }
}

/// Just before we render the frame
bool Character::frameRenderingQueued(const FrameEvent& evt) {
    if ( !getBoundNode() ) {
        return false;
    }
    PhysicsComponent* const nodePhysicsComponent = getBoundNode()->getComponent<PhysicsComponent>();

    vec3<F32> sourceDirection(getLookingDirection());
    sourceDirection.y = 0.0f;

    _oldPosition.set( nodePhysicsComponent->getPosition() );
    _oldPosition.lerp(_curPosition, GFX_DEVICE.getInterpolation());  
    nodePhysicsComponent->setPosition(_oldPosition);
    nodePhysicsComponent->rotateSlerp(nodePhysicsComponent->getOrientation() * rotationFromVToU( sourceDirection, _curVelocity ), 
                                      GFX_DEVICE.getInterpolation());
    return true;
}

void Character::setPosition(const vec3<F32>& newPosition){
    _newPosition.set(newPosition);
    _positionDirty = true;
}

void Character::setVelocity(const vec3<F32>& newVelocity){
    _newVelocity.set(newVelocity);
    _velocityDirty = true;
}

vec3<F32> Character::getPosition() const {
    return _curPosition;
}

vec3<F32> Character::getLookingDirection() {
    if(getBoundNode())
        return getBoundNode()->getComponent<PhysicsComponent>()->getOrientation() * getRelativeLookingDirection();
    
    return getRelativeLookingDirection();
}

void Character::lookAt(const vec3<F32>& targetPos) {
    if(!getBoundNode()) 
        return;
    _newVelocity.set(getBoundNode()->getComponent<PhysicsComponent>()->getPosition().direction(targetPos));
    _velocityDirty = true;
}


};

Commits for Divide-Framework/trunk/Source Code/Dynamics/Entities/Units/Character.cpp

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

329 Diff Diff IonutCava picture IonutCava Tue 07 Oct, 2014 12:51:37 +0000

[Ionut]
- Modified material class and shaders to support multiple BRDFs (currently, only Flat, Phong and Blinn-Phong supported with Cook-Torrance and Oren-Nayar in future commits)
- Optimized transform updates and queries
- Fixed an indirect draw command (no buffer was bound to GL_DRAW_INDIRECT_BUFFER, violating a core requirement)

325 Diff Diff IonutCava picture IonutCava Wed 17 Sep, 2014 20:06:13 +0000

[Ionut]
- Reworked transform system:
— Parent transform chain system moved from Transform class to the PhysicsComponent
— PhysicsComponent now returns all transform values needed both global and local (still needs heavy optimization and caching)

- Reworked SceneGraph node management:
— Proper ref counting of SceneNodes and proper removing of resource (ResourceCache is now empty on destruction, as it should be)
— Removed parent transform tracking as that’s the PhysicsComponent’s responsibility
— Only nodes loaded via the ResourceCache are allowed to be added to the SceneGraph (added proper loaders for Impostors, Sky, etc)

- Optimized some of the math classes (mat4, mat3)

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

308 Diff Diff IonutCava picture IonutCava Sat 16 Aug, 2014 19:49:31 +0000

[Ionut]
- Moved Transform from SceneGraphNode to PhysicsComponent and modified BoundingBox update system based on transform update
- Added PhysicsAsset to PhysicsComponent for interfacing with PshysicsAPIs (e.g. PhysXActor inherits PhysicsAsset)
- PhysicsAsset keeps track of the parent PhysicsComponent to have direct access to a node’s transform
- Rewrote GUIConsole to only print items when visible, and use a single circular buffer for entries.
- Updated GUI input system to match the interface that both Kernel and SceneManager share (should probably abstract all the input methods in a class and have Kernel, SceneManager, Scene and GUI inherit from that. In next commit.)
- Updated CEGUI to probably match the OIS states(mouse, keyboard, etc) and properly inject time inputs.

294 Diff Diff k1ngp1n picture k1ngp1n Wed 30 Jul, 2014 20:19:14 +0000

[Ionut]
- More nVidia compatibility fixes (lighting shaders with textures still fail to compile):
— NS_GLIM compatibility fix (set ELEMENT_ARRAY_BUFFER to 0 in glimBatchData’s VAO on creation when setting attrib pointers)

  • Could improve NS_GLIM performance a lot by caching some buffers instead of re-creating them every time a batch is generated, but it’s suppose to be used only for debugging, so low prio*

- Removed interpolation factor from FrameEvent struct. Only using interpolation factor stored in GFXDevice instance
- Fixed the close button (added GLFW close callback)
- More code style improvements (no new comments yet)

249 Diff Diff k1ngp1n picture k1ngp1n Mon 31 Mar, 2014 20:42:31 +0000

[Ionut] [[BR]]
- Migrated to platform toolset v100 [[BR]]
- Updated boost to 1.55 [[BR]]
- Moved from “NULL” to “nullptr” [[BR]]
- DevIL is now linked dynamically [[BR]]

247 Diff Diff k1ngp1n picture k1ngp1n Sun 16 Feb, 2014 16:36:06 +0000

[Ionut] [[BR]]
- Fixed VSM rendering [[BR]]
- Added Z-prePass as a separate render stage [[BR]]
- Added GL error checking and asserts to “Profile” builds [[BR]]
- Fixed bad XML material dump (invalid file name bug) [[BR]]
- Fixed random crashes [[BR]]
- Shadow cast/receive is now a node property, and not a material property [[BR]]
- Fixed an issue with previous RenderPassManager lock mechanism (clearing the queue on frame end to prevent infinite lock) [[BR]]
- Added depth buffer preview (F10 key) [[BR]]

242 k1ngp1n picture k1ngp1n Mon 03 Feb, 2014 21:05:28 +0000

[Ionut] [[BR]]
- Smoother third person camera [[BR]]
- Smoother Character movement [[BR]]
- Limit third person camera rotations (-179 ... + 179 yaw, -31.5 ... +60 pitch) [[BR]]
- Character and third person camera performance optimizations [[BR]]