mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
this snowballed into a massive search+destroy of the hodgepodge of mostly equivalent types we had in use (int, uint, unsigned, unsigned int, i32, u32, ulong, uintN). it is more efficient to use 64-bit types in 64-bit mode, so the preferred default is size_t (for anything remotely resembling a size or index). tile coordinates are ssize_t to allow more efficient conversion to/from floating point. flags are int because we almost never need more than 15 distinct bits, bit test/set is not slower and int is fastest to type. finally, some data that is pretty much directly passed to OpenGL is now typed accordingly. after several hours, the code now requires fewer casts and less guesswork. other changes: - unit and player IDs now have an "invalid id" constant in the respective class to avoid casting and -1 - fix some endian/64-bit bugs in the map (un)packing. added a convenience function to write/read a size_t. - ia32: change CPUID interface to allow passing in ecx (required for cache topology detection, which I need at work). remove some unneeded functions from asm, replace with intrinsics where possible. This was SVN commit r5942.
84 lines
2.1 KiB
C++
84 lines
2.1 KiB
C++
// JSInterface_Camera.h
|
|
//
|
|
// A JavaScript wrapper around a camera object.
|
|
//
|
|
// Usage: When manipulating objects of type 'Camera' in JavaScript
|
|
|
|
#include "scripting/ScriptingHost.h"
|
|
|
|
#include "maths/Vector3D.h"
|
|
#include "graphics/Camera.h"
|
|
#include "graphics/HFTracer.h"
|
|
|
|
#ifndef INCLUDED_JSI_CAMERA
|
|
#define INCLUDED_JSI_CAMERA
|
|
|
|
namespace JSI_Camera
|
|
{
|
|
enum
|
|
{
|
|
vector_position,
|
|
vector_orientation,
|
|
vector_up
|
|
};
|
|
|
|
enum
|
|
{
|
|
lookat
|
|
};
|
|
|
|
struct Camera_Info : public IPropertyOwner
|
|
{
|
|
CCamera* m_Data;
|
|
bool m_EngineOwned;
|
|
CVector3D m_sv_Position;
|
|
CVector3D m_sv_Orientation;
|
|
CVector3D m_sv_Up;
|
|
CVector3D m_sv_Target;
|
|
|
|
Camera_Info(); // Create a camera set to the initial view
|
|
|
|
Camera_Info( const CVector3D& Position );
|
|
Camera_Info( const CVector3D& Position, const CVector3D& Orientation );
|
|
Camera_Info( const CVector3D& Position, const CVector3D& Orientation, const CVector3D& Up );
|
|
Camera_Info( const CMatrix3D& Orientation );
|
|
Camera_Info( CCamera* copy );
|
|
|
|
void Initialise();
|
|
void Initialise( const CMatrix3D& Orientation );
|
|
|
|
void Freshen();
|
|
void Update();
|
|
void FreshenTarget();
|
|
|
|
~Camera_Info();
|
|
/*
|
|
|
|
Camera_Info( const CVector3D& _position );
|
|
Camera_Info( const CVector3D& _position, const CVector3D& _orientation );
|
|
Camera_Info( const CVector3D& _position, const CVector3D& _orientation, const CVector3D& _up );
|
|
Camera_Info( CCamera* _copy );
|
|
void update();
|
|
|
|
*/
|
|
};
|
|
extern JSClass JSI_class;
|
|
extern JSPropertySpec JSI_props[];
|
|
extern JSFunctionSpec JSI_methods[];
|
|
|
|
JSBool getProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
JSBool setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
|
|
JSBool getCamera( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
JSBool setCamera( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
|
|
|
JSBool construct( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
void finalize( JSContext* cx, JSObject* obj );
|
|
|
|
JSBool lookAt( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
JSBool getFocus( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval );
|
|
|
|
void init();
|
|
}
|
|
|
|
#endif
|